@@ -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 ;
@@ -245,6 +246,7 @@ fn insert_required_predicates_to_be_wf<'tcx>(
245
246
}
246
247
}
247
248
249
+ #[ derive( Debug ) ]
248
250
pub struct IgnoreSelfTy ( bool ) ;
249
251
250
252
/// We also have to check the explicit predicates
@@ -270,10 +272,18 @@ pub fn check_explicit_predicates<'tcx>(
270
272
explicit_map : & mut ExplicitPredicatesMap < ' tcx > ,
271
273
ignore_self_ty : IgnoreSelfTy ,
272
274
) {
273
- debug ! ( "def_id = {:?}" , & def_id) ;
274
- debug ! ( "substs = {:?}" , & substs) ;
275
- debug ! ( "explicit_map = {:?}" , explicit_map) ;
276
- debug ! ( "required_predicates = {:?}" , required_predicates) ;
275
+ debug ! (
276
+ "check_explicit_predicates(def_id={:?}, \
277
+ substs={:?}, \
278
+ explicit_map={:?}, \
279
+ required_predicates={:?}, \
280
+ ignore_self_ty={:?})",
281
+ def_id,
282
+ substs,
283
+ explicit_map,
284
+ required_predicates,
285
+ ignore_self_ty,
286
+ ) ;
277
287
let explicit_predicates = explicit_map. explicit_predicates_of ( tcx, * def_id) ;
278
288
279
289
for outlives_predicate in explicit_predicates. iter ( ) {
@@ -302,13 +312,23 @@ pub fn check_explicit_predicates<'tcx>(
302
312
//
303
313
// Note that we do this check for self **before** applying `substs`. In the
304
314
// case that `substs` come from a `dyn Trait` type, our caller will have
305
- // 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
306
316
// to apply the substs, and not filter this predicate, we might then falsely
307
317
// conclude that e.g. `X: 'x` was a reasonable inferred requirement.
308
- if let UnpackedKind :: Type ( ty) = outlives_predicate. 0 . unpack ( ) {
309
- if ty. is_self ( ) && ignore_self_ty. 0 {
310
- debug ! ( "skipping self ty = {:?}" , & ty) ;
311
- 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
+ }
312
332
}
313
333
}
314
334
0 commit comments