]> git.lizzy.rs Git - rust.git/commitdiff
Split fold_opaque_ty
authorOli Scherer <github35764891676564198441@oli-obk.de>
Tue, 27 Jul 2021 11:46:31 +0000 (11:46 +0000)
committerOli Scherer <github35764891676564198441@oli-obk.de>
Fri, 6 Aug 2021 10:23:11 +0000 (10:23 +0000)
compiler/rustc_trait_selection/src/opaque_types.rs

index f74b9070535c0c28dd54911ff2698f547c25c5c1..8f23cc9e133f2df61479fbb0b7f09b79998ee80c 100644 (file)
@@ -999,6 +999,19 @@ fn fold_opaque_ty(
             OpaqueTypeDecl { opaque_type: ty, definition_span, concrete_ty: ty_var, origin },
         );
         debug!("instantiate_opaque_types: ty_var={:?}", ty_var);
+        self.compute_opaque_type_obligations(opaque_type_key, span);
+
+        ty_var
+    }
+
+    fn compute_opaque_type_obligations(
+        &mut self,
+        opaque_type_key: OpaqueTypeKey<'tcx>,
+        span: Span,
+    ) {
+        let infcx = self.infcx;
+        let tcx = infcx.tcx;
+        let OpaqueTypeKey { def_id, substs } = opaque_type_key;
 
         let item_bounds = tcx.explicit_item_bounds(def_id);
         debug!("instantiate_opaque_types: bounds={:#?}", item_bounds);
@@ -1019,7 +1032,7 @@ fn fold_opaque_ty(
             if let ty::PredicateKind::Projection(projection) = predicate.kind().skip_binder() {
                 if projection.ty.references_error() {
                     // No point on adding these obligations since there's a type error involved.
-                    return ty_var;
+                    return;
                 }
             }
         }
@@ -1037,8 +1050,6 @@ fn fold_opaque_ty(
             debug!("instantiate_opaque_types: predicate={:?}", predicate);
             self.obligations.push(traits::Obligation::new(cause, self.param_env, predicate));
         }
-
-        ty_var
     }
 }