rust/tests/ui/object-safety
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
..
almost-supertrait-associated-type.rs
almost-supertrait-associated-type.stderr
assoc_const_bounds_sized.rs
assoc_const_bounds.rs
assoc_type_bounds2.rs
assoc_type_bounds2.stderr
assoc_type_bounds_implicit_sized.fixed
assoc_type_bounds_implicit_sized.rs
assoc_type_bounds_implicit_sized.stderr
assoc_type_bounds_sized_others.rs
assoc_type_bounds_sized_others.stderr
assoc_type_bounds_sized_unnecessary.rs
assoc_type_bounds_sized_unnecessary.stderr
assoc_type_bounds_sized_used.rs
assoc_type_bounds_sized_used.stderr
assoc_type_bounds_sized.rs
assoc_type_bounds.rs
assoc_type_bounds.stderr
avoid-ice-on-warning-2.new.stderr
avoid-ice-on-warning-2.old.stderr
avoid-ice-on-warning-2.rs
avoid-ice-on-warning-3.new.stderr
avoid-ice-on-warning-3.old.stderr
avoid-ice-on-warning-3.rs
avoid-ice-on-warning.new.stderr
avoid-ice-on-warning.old.stderr
avoid-ice-on-warning.rs
bare-trait-dont-suggest-dyn.new.fixed
bare-trait-dont-suggest-dyn.new.stderr
bare-trait-dont-suggest-dyn.old.stderr
bare-trait-dont-suggest-dyn.rs
call-when-assoc-ty-is-sized.rs
erroneous_signature.rs
erroneous_signature.stderr
issue-19538.rs
issue-19538.stderr
issue-102762.rs
issue-102762.stderr
issue-102933.rs
issue-106247.rs
item-bounds-can-reference-self.rs
object-safety-associated-consts.curr.stderr
object-safety-associated-consts.object_safe_for_dispatch.stderr
object-safety-associated-consts.rs
object-safety-bounds.rs
object-safety-bounds.stderr
object-safety-by-value-self-use.rs
object-safety-by-value-self-use.stderr
object-safety-by-value-self.rs
object-safety-generics.curr.stderr
object-safety-generics.object_safe_for_dispatch.stderr
object-safety-generics.rs
object-safety-issue-22040.rs
object-safety-issue-22040.stderr
object-safety-mentions-Self.curr.stderr
object-safety-mentions-Self.object_safe_for_dispatch.stderr
object-safety-mentions-Self.rs
object-safety-no-static.curr.stderr
object-safety-no-static.object_safe_for_dispatch.stderr
object-safety-no-static.rs
object-safety-phantom-fn.rs
object-safety-sized-2.curr.stderr
object-safety-sized-2.object_safe_for_dispatch.stderr
object-safety-sized-2.rs
object-safety-sized.curr.stderr
object-safety-sized.object_safe_for_dispatch.stderr
object-safety-sized.rs
object-safety-supertrait-mentions-GAT.rs
object-safety-supertrait-mentions-GAT.stderr
object-safety-supertrait-mentions-Self.rs
object-safety-supertrait-mentions-Self.stderr
reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs Suggest impl Trait for References to Bare Trait in Function Header 2024-08-19 15:19:43 -04:00
reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.stderr Suggest impl Trait for References to Bare Trait in Function Header 2024-08-19 15:19:43 -04:00