Rollup merge of #137635 - compiler-errors:constrain-unstable, r=SparrowLii

Don't suggest constraining unstable associated types

Fixes #137624

This could be made a bit more specific, considering the local crate's stability or nightly status or something, but I think in general we should not be suggesting associated type bounds on unstable associated items.
This commit is contained in:
León Orell Valerian Liehr 2025-02-26 19:03:57 +01:00 committed by GitHub
commit 875e390589
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 1 deletions

View file

@ -136,7 +136,10 @@ pub fn suggest_restriction<'tcx, G: EmissionGuarantee>(
) {
if hir_generics.where_clause_span.from_expansion()
|| hir_generics.where_clause_span.desugaring_kind().is_some()
|| projection.is_some_and(|projection| tcx.is_impl_trait_in_trait(projection.def_id))
|| projection.is_some_and(|projection| {
tcx.is_impl_trait_in_trait(projection.def_id)
|| tcx.lookup_stability(projection.def_id).is_some_and(|stab| stab.is_unstable())
})
{
return;
}