required_predicates: &mut RequiredPredicates<'tcx>,
explicit_map: &mut ExplicitPredicatesMap<'tcx>,
) {
- for arg in field_ty.walk() {
+ // We must not look into the default substs of consts
+ // as computing those depends on the results of `predicates_of`.
+ //
+ // Luckily the only types contained in default substs are type
+ // parameters which don't matter here.
+ //
+ // FIXME(adt_const_params): Once complex const parameter types
+ // are allowed, this might be incorrect. I think that we will still be
+ // fine, as all outlives relations of the const param types should also
+ // be part of the adt containing it, but we should still both update the
+ // documentation and add some tests for this.
+ for arg in field_ty.walk_ignoring_default_const_substs() {
let ty = match arg.unpack() {
GenericArgKind::Type(ty) => ty,
// to apply the substs, and not filter this predicate, we might then falsely
// conclude that e.g., `X: 'x` was a reasonable inferred requirement.
//
- // Another similar case is where we have a inferred
+ // Another similar case is where we have an inferred
// requirement like `<Self as Trait>::Foo: 'b`. We presently
// ignore such requirements as well (cc #54467)-- though
// conceivably it might be better if we could extract the `Foo
// 'b`.
if let Some(self_ty) = ignored_self_ty {
if let GenericArgKind::Type(ty) = outlives_predicate.0.unpack() {
- if ty.walk().any(|arg| arg == self_ty.into()) {
+ if ty.walk(tcx).any(|arg| arg == self_ty.into()) {
debug!("skipping self ty = {:?}", &ty);
continue;
}