rust/compiler/rustc_trait_selection/src
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
..
error_reporting Rollup merge of #133292 - dianne:e0277-suggest-deref, r=estebank 2025-01-01 16:35:30 +11:00
errors introduce LateParamRegionKind 2024-12-18 16:05:44 +01:00
solve remove non-borrowck member constraints 2024-12-20 10:04:01 +01:00
traits Make sure we check the future type is Sized in AsyncFn* 2024-12-31 00:46:46 +00:00
errors.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
infer.rs remove Ty::is_copy_modulo_regions 2024-12-02 13:57:56 +01:00
lib.rs consistently handle global where-bounds 2024-12-17 08:50:47 +01:00
regions.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
solve.rs impossible obligations check fast path 2024-10-10 06:09:50 -04:00