rust/compiler/rustc_trait_selection
Stuart Cook 0204259780
Rollup merge of #133292 - dianne:e0277-suggest-deref, r=estebank
E0277: suggest dereferencing function arguments in more cases

This unifies and generalizes some of the logic in `TypeErrCtxt::suggest_dereferences` so that it will suggest dereferencing arguments to function/method calls in order to satisfy trait bounds in more cases.

Previously it would only fire on reference types, and it had two separate cases (one specifically to get through custom `Deref` impls when passing by-reference, and one specifically to catch #87437). I've based the new checks loosely on what's done for `E0308` in `FnCtxt::suggest_deref_or_ref`: it will suggest dereferences to satisfy trait bounds whenever the referent is `Copy`, is boxed (& so can be moved out of the boxes), or is being passed by reference.

This doesn't make the suggestion fire in contexts other than function arguments or binary operators (which are in a separate case that this doesn't touch), and doesn't make it suggest a combination of `&`-removal and dereferences. Those would require a bit more restructuring, so I figured just doing this would be a decent first step.

Closes #90997
2025-01-01 16:35:30 +11:00
..
src Rollup merge of #133292 - dianne:e0277-suggest-deref, r=estebank 2025-01-01 16:35:30 +11:00
Cargo.toml rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structures 2024-12-16 19:08:19 +01:00
messages.ftl Dont suggest use<APIT> 2024-11-09 19:41:53 +00:00