about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
diff options
context:
space:
mode:
authortrevyn <230691+trevyn@users.noreply.github.com>2024-02-14 12:42:32 -0800
committertrevyn <230691+trevyn@users.noreply.github.com>2024-02-14 12:42:32 -0800
commit220e8a7484de6fd4e2679a3f6577ba879be73204 (patch)
tree63d80b0d7d67860e89fc5a0e08fa8692558a62d4 /compiler/rustc_trait_selection
parent502ce8287bc3c86dca07acc38c5ff9431a6097be (diff)
downloadrust-220e8a7484de6fd4e2679a3f6577ba879be73204.tar.gz
rust-220e8a7484de6fd4e2679a3f6577ba879be73204.zip
For E0038, suggest associated type if available
Diffstat (limited to 'compiler/rustc_trait_selection')
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs9
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 2c8d3fc9de2..e4ae2440384 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
@@ -2922,6 +2922,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()
+            }
         }
     }