1
Fork 0
rust/compiler/rustc_hir_analysis/src
Matthias Krüger f75a1954eb
Rollup merge of #127692 - veera-sivarajan:bugfix-125139, r=estebank
Suggest `impl Trait` for References to Bare Trait in Function Header

Fixes #125139

This PR suggests `impl Trait` when `&Trait` is found as a function parameter type or return type. This makes use of existing diagnostics by adding `peel_refs()` when checking for type equality.

Additionaly, it makes a few other improvements:
1. Checks if functions inside impl blocks have bare trait in their headers.
2. Introduces a trait `NextLifetimeParamName` similar to the existing `NextTypeParamName` for suggesting a lifetime name. Also, abstracts out the common logic between the two trait impls.

### Related Issues
I ran into a bunch of related diagnostic issues but couldn't fix them within the scope of this PR. So, I have created the following issues:
1. [Misleading Suggestion when Returning a Reference to a Bare Trait from a Function](https://github.com/rust-lang/rust/issues/127689)
2. [Verbose Error When a Function Takes a Bare Trait as Parameter](https://github.com/rust-lang/rust/issues/127690)
3. [Incorrect Suggestion when Returning a Bare Trait from a Function](https://github.com/rust-lang/rust/issues/127691)

r​? ```@estebank``` since you implemented  #119148
2024-09-03 19:13:23 +02:00
..
check chore: Fix typos in 'compiler' (batch 1) 2024-09-02 07:42:38 +02:00
coherence chore: Fix typos in 'compiler' (batch 1) 2024-09-02 07:42:38 +02:00
collect Rollup merge of #129767 - nnethercote:rm-extern-crate-tracing-4, r=jieyouxu 2024-08-31 14:46:11 +02:00
errors Remove #[macro_use] extern crate tracing from rustc_hir_analysis. 2024-08-30 17:14:59 +10:00
hir_ty_lowering Rollup merge of #127692 - veera-sivarajan:bugfix-125139, r=estebank 2024-09-03 19:13:23 +02:00
impl_wf_check Remove #[macro_use] extern crate tracing from rustc_hir_analysis. 2024-08-30 17:14:59 +10:00
outlives Remove #[macro_use] extern crate tracing from rustc_hir_analysis. 2024-08-30 17:14:59 +10:00
variance Remove #[macro_use] extern crate tracing from rustc_hir_analysis. 2024-08-30 17:14:59 +10:00
autoderef.rs Remove #[macro_use] extern crate tracing from rustc_hir_analysis. 2024-08-30 17:14:59 +10:00
bounds.rs Add warn(unreachable_pub) to rustc_hir_analysis. 2024-08-27 13:14:50 +10:00
check_unused.rs Remove #[macro_use] extern crate tracing from rustc_hir_analysis. 2024-08-30 17:14:59 +10:00
collect.rs chore: Fix typos in 'compiler' (batch 1) 2024-09-02 07:42:38 +02:00
constrained_generic_params.rs Remove #[macro_use] extern crate tracing from rustc_hir_analysis. 2024-08-30 17:14:59 +10:00
delegation.rs Use assert_matches around the compiler 2024-08-11 12:25:39 -04:00
errors.rs Add warn(unreachable_pub) to rustc_hir_analysis. 2024-08-27 13:14:50 +10:00
hir_wf_check.rs Remove #[macro_use] extern crate tracing from rustc_hir_analysis. 2024-08-30 17:14:59 +10:00
impl_wf_check.rs Add warn(unreachable_pub) to rustc_hir_analysis. 2024-08-27 13:14:50 +10:00
lib.rs Remove #[macro_use] extern crate tracing from rustc_hir_analysis. 2024-08-30 17:14:59 +10:00