]> git.proxmox.com Git - rustc.git/blobdiff - compiler/rustc_typeck/src/outlives/implicit_infer.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / compiler / rustc_typeck / src / outlives / implicit_infer.rs
index 6e6ecf6a22b51815c0976a62b36d6c467ff5901d..0e96601d89fd8d91204a0ee3af63b69c60fbd0c0 100644 (file)
@@ -114,7 +114,18 @@ fn insert_required_predicates_to_be_wf<'tcx>(
     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,
 
@@ -297,7 +308,7 @@ pub fn check_explicit_predicates<'tcx>(
         // 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
@@ -306,7 +317,7 @@ pub fn check_explicit_predicates<'tcx>(
         // '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;
                 }