@@ -14,6 +14,7 @@ use rustc::hir::def_id::DefId;
1414use rustc:: hir:: itemlikevisit:: ItemLikeVisitor ;
1515use rustc:: ty:: subst:: { Kind , Subst , UnpackedKind } ;
1616use rustc:: ty:: { self , Ty , TyCtxt } ;
17+ use rustc:: ty:: fold:: TypeFoldable ;
1718use rustc:: util:: nodemap:: FxHashMap ;
1819
1920use super :: explicit:: ExplicitPredicatesMap ;
@@ -311,13 +312,23 @@ pub fn check_explicit_predicates<'tcx>(
311312 //
312313 // Note that we do this check for self **before** applying `substs`. In the
313314 // case that `substs` come from a `dyn Trait` type, our caller will have
314- // included `Self = dyn Trait<'x, X> ` as the value for `Self`. If we were
315+ // included `Self = usize ` as the value for `Self`. If we were
315316 // to apply the substs, and not filter this predicate, we might then falsely
316317 // conclude that e.g. `X: 'x` was a reasonable inferred requirement.
317- if let UnpackedKind :: Type ( ty) = outlives_predicate. 0 . unpack ( ) {
318- if ty. is_self ( ) && ignore_self_ty. 0 {
319- debug ! ( "skipping self ty = {:?}" , & ty) ;
320- continue ;
318+ //
319+ // Another similar case is where we have a inferred
320+ // requirement like `<Self as Trait>::Foo: 'b`. We presently
321+ // ignore such requirements as well (cc #54467)-- though
322+ // conceivably it might be better if we could extract the `Foo
323+ // = X` binding from the object type (there must be such a
324+ // binding) and thus infer an outlives requirement that `X:
325+ // 'b`.
326+ if ignore_self_ty. 0 {
327+ if let UnpackedKind :: Type ( ty) = outlives_predicate. 0 . unpack ( ) {
328+ if ty. has_self_ty ( ) {
329+ debug ! ( "skipping self ty = {:?}" , & ty) ;
330+ continue ;
331+ }
321332 }
322333 }
323334
0 commit comments