Don't perform selection if IATs are not enabled

This commit is contained in:
León Orell Valerian Liehr 2023-07-03 13:34:54 +02:00
parent 6162f6f123
commit 838f85d6f7
No known key found for this signature in database
GPG key ID: D17A07215F68E713
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.
//