1
Fork 0

Rollup merge of #113286 - fmease:iat-dont-select-if-not-enabled, r=compiler-errors

Don't perform selection if inherent associated types are not enabled

Fixes #113265.

As discussed
r? `@compiler-errors`
This commit is contained in:
Guillaume Gomez 2023-07-03 18:46:14 +02:00 committed by GitHub
commit 157bab670f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 99 additions and 46 deletions

View file

@ -1893,6 +1893,15 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
) -> Result<Option<(Ty<'tcx>, DefId)>, ErrorGuaranteed> {
let tcx = self.tcx();
// Don't attempt to look up inherent associated types when the feature is not enabled.
// Theoretically it'd be fine to do so since we feature-gate their definition site.
// However, due to current limitations of the implementation (caused by us performing
// selection in AstConv), IATs can lead to cycle errors (#108491, #110106) which mask the
// feature-gate error, needlessly confusing users that use IATs by accident (#113265).
if !tcx.features().inherent_associated_types {
return Ok(None);
}
let candidates: Vec<_> = tcx
.inherent_impls(adt_did)
.iter()
@ -1903,11 +1912,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
return Ok(None);
}
if !tcx.features().inherent_associated_types {
tcx.sess
.delay_span_bug(span, "found inherent assoc type without the feature being gated");
}
//
// Select applicable inherent associated type candidates modulo regions.
//