rust/tests/ui/dyn-keyword
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
..
dyn-2015-edition-keyword-ident-lint.fixed [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
dyn-2015-edition-keyword-ident-lint.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
dyn-2015-edition-keyword-ident-lint.stderr Deny gen keyword in edition_2024_compat lints 2024-04-22 11:51:50 -04:00
dyn-2015-idents-in-decl-macros-unlinted.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
dyn-2015-idents-in-macros-unlinted.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
dyn-2015-no-warnings-without-lints.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
dyn-2018-edition-lint.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
dyn-2018-edition-lint.stderr Be less confident when `dyn` suggestion is not checked for object safety 2024-02-09 20:47:50 -08:00
dyn-2021-edition-error.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
dyn-2021-edition-error.stderr Update Tests 2024-07-13 11:49:14 -04:00
dyn-angle-brackets.fixed [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
dyn-angle-brackets.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
dyn-angle-brackets.stderr Be less confident when `dyn` suggestion is not checked for object safety 2024-02-09 20:47:50 -08:00
issue-5153.rs Move tests 2024-03-03 16:30:48 -03:00
issue-5153.stderr Move tests 2024-03-03 16:30:48 -03:00
issue-56327-dyn-trait-in-macro-is-okay.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
suggest-dyn-on-bare-trait-in-pat.rs Remove redundant flags that can be inferred from the HIR 2024-08-25 16:21:00 -04:00
suggest-dyn-on-bare-trait-in-pat.stderr Remove redundant flags that can be inferred from the HIR 2024-08-25 16:21:00 -04:00