@@ -1481,11 +1481,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
14811481 match assoc_tag {
14821482 // Don't attempt to look up inherent associated types when the feature is not
14831483 // enabled. Theoretically it'd be fine to do so since we feature-gate their
1484- // definition site. However, due to current limitations of the implementation
1485- // (caused by us performing selection during HIR ty lowering instead of in the
1486- // trait solver), IATs can lead to cycle errors (#108491) which mask the
1487- // feature-gate error, needlessly confusing users who use IATs by accident
1488- // (#113265).
1484+ // definition site. However, the current implementation of inherent associated
1485+ // items is somewhat brittle, so let's not run it by default.
14891486 ty:: AssocTag :: Type => return Ok ( None ) ,
14901487 ty:: AssocTag :: Const => {
14911488 // We also gate the mgca codepath for type-level uses of inherent consts
@@ -1508,15 +1505,25 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
15081505 . inherent_impls ( adt_did)
15091506 . iter ( )
15101507 . filter_map ( |& impl_| {
1508+ // FIXME: Don't eagerly
15111509 let ( item, scope) =
15121510 self . probe_assoc_item_unchecked ( name, assoc_tag, block, impl_) ?;
15131511 Some ( InherentAssocCandidate { impl_, assoc_item : item. def_id , scope } )
15141512 } )
15151513 . collect ( ) ;
15161514
1515+ // At the moment, we actually bail out with a hard error if the selection of an inherent
1516+ // associated item fails (see below). This means we never consider trait associated items
1517+ // as potential fallback candidates (#142006). To temporarily mask that issue, let's not
1518+ // select at all if there are no early inherent candidates.
1519+ if candidates. is_empty ( ) {
1520+ return Ok ( None ) ;
1521+ }
1522+
15171523 let ( applicable_candidates, fulfillment_errors) =
15181524 self . select_inherent_assoc_candidates ( span, self_ty, candidates. clone ( ) ) ;
15191525
1526+ // FIXME(#142006): Don't eagerly error here, there might be applicable trait candidates.
15201527 let InherentAssocCandidate { impl_, assoc_item, scope : def_scope } =
15211528 match & applicable_candidates[ ..] {
15221529 & [ ] => Err ( self . report_unresolved_inherent_assoc_item (
@@ -1537,6 +1544,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
15371544 ) ) ,
15381545 } ?;
15391546
1547+ // FIXME(#142006): Don't eagerly validate here, there might be trait candidates that are
1548+ // accessible (visible and stable) contrary to the inherent candidate.
15401549 self . check_assoc_item ( assoc_item, name, def_scope, block, span) ;
15411550
15421551 // FIXME(fmease): Currently creating throwaway `parent_args` to please
0 commit comments