@@ -14,6 +14,7 @@ use rustc::hir::def_id::DefId;
14
14
use rustc:: hir:: itemlikevisit:: ItemLikeVisitor ;
15
15
use rustc:: ty:: subst:: { Kind , Subst , UnpackedKind } ;
16
16
use rustc:: ty:: { self , Ty , TyCtxt } ;
17
+ use rustc:: ty:: fold:: TypeFoldable ;
17
18
use rustc:: util:: nodemap:: FxHashMap ;
18
19
19
20
use super :: explicit:: ExplicitPredicatesMap ;
@@ -311,13 +312,23 @@ pub fn check_explicit_predicates<'tcx>(
311
312
//
312
313
// Note that we do this check for self **before** applying `substs`. In the
313
314
// 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
315
316
// to apply the substs, and not filter this predicate, we might then falsely
316
317
// 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
+ }
321
332
}
322
333
}
323
334
0 commit comments