]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_trait_selection/src/solve/mod.rs
remove assembly context and impl a bit more
[rust.git] / compiler / rustc_trait_selection / src / solve / mod.rs
index 0e629664b2b1a9d13ca3037f2c29f6cad7852cf4..579cd6a2d59cde4d0469ee928b6ea68fb918e782 100644 (file)
@@ -155,6 +155,23 @@ struct EvalCtxt<'a, 'tcx> {
 }
 
 impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
+    fn tcx(&self) -> TyCtxt<'tcx> {
+        self.infcx.tcx
+    }
+
+    /// Creates a new evaluation context outside of the trait solver.
+    ///
+    /// With this solver making a canonical response doesn't make much sense.
+    /// The `search_graph` for this solver has to be completely empty.
+    fn new_outside_solver(
+        infcx: &'a InferCtxt<'tcx>,
+        search_graph: &'a mut search_graph::SearchGraph<'tcx>,
+    ) -> EvalCtxt<'a, 'tcx> {
+        assert!(search_graph.is_empty());
+        EvalCtxt { infcx, var_values: CanonicalVarValues::dummy(), search_graph }
+    }
+
+    #[instrument(level = "debug", skip(tcx, search_graph), ret)]
     fn evaluate_canonical_goal(
         tcx: TyCtxt<'tcx>,
         search_graph: &'a mut search_graph::SearchGraph<'tcx>,
@@ -183,10 +200,6 @@ fn evaluate_canonical_goal(
         }
     }
 
-    fn tcx(&self) -> TyCtxt<'tcx> {
-        self.infcx.tcx
-    }
-
     fn make_canonical_response(&self, certainty: Certainty) -> QueryResult<'tcx> {
         let external_constraints = take_external_constraints(self.infcx)?;