1
Fork 0

Rollup merge of #121111 - trevyn:associated-type-suggestion, r=davidtwco

For E0038, suggest associated type if available

Closes #116434
This commit is contained in:
Guillaume Gomez 2024-02-16 17:08:12 +01:00 committed by GitHub
commit 670bdbf808
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 58 additions and 6 deletions

View file

@ -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()
}
}
}