diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-02-16 17:08:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-16 17:08:12 +0100 |
| commit | 670bdbf8083760f5df1b1a3f4d24cdb395491790 (patch) | |
| tree | 1189a3a532962ec2908f41f1b0e846189b62bce8 /compiler/rustc_trait_selection/src/traits | |
| parent | e5a743c4c2b7f5404ee4e0c0d66a6bbe8cbf5c98 (diff) | |
| parent | 220e8a7484de6fd4e2679a3f6577ba879be73204 (diff) | |
| download | rust-670bdbf8083760f5df1b1a3f4d24cdb395491790.tar.gz rust-670bdbf8083760f5df1b1a3f4d24cdb395491790.zip | |
Rollup merge of #121111 - trevyn:associated-type-suggestion, r=davidtwco
For E0038, suggest associated type if available Closes #116434
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs index 68b1a0d4e61..661a444d049 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs @@ -2993,6 +2993,15 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { &mut Default::default(), ); self.suggest_unsized_bound_if_applicable(err, obligation); + if let Some(span) = err.span.primary_span() + && let Some(mut diag) = + self.tcx.dcx().steal_diagnostic(span, StashKey::AssociatedTypeSuggestion) + && let Ok(ref mut s1) = err.suggestions + && let Ok(ref mut s2) = diag.suggestions + { + s1.append(s2); + diag.cancel() + } } } |
