From ea08d3a47cee34f9943a2ca850ac7b3435fb499e Mon Sep 17 00:00:00 2001 From: Boxy Date: Fri, 17 Mar 2023 13:37:47 +0000 Subject: [PATCH] add assert --- compiler/rustc_trait_selection/src/solve/mod.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_trait_selection/src/solve/mod.rs b/compiler/rustc_trait_selection/src/solve/mod.rs index 089c5f8fb4df..ba68ff1c2e33 100644 --- a/compiler/rustc_trait_selection/src/solve/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/mod.rs @@ -78,15 +78,22 @@ impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> { ) -> Result<(bool, Certainty), NoSolution> { let mut search_graph = search_graph::SearchGraph::new(self.tcx); - let result = EvalCtxt { + let mut ecx = EvalCtxt { search_graph: &mut search_graph, infcx: self, // Only relevant when canonicalizing the response. max_input_universe: ty::UniverseIndex::ROOT, var_values: CanonicalVarValues::dummy(), nested_goals: NestedGoals::new(), + }; + let result = ecx.evaluate_goal(IsNormalizesToHack::No, goal); + + if let Ok((_, Certainty::Yes)) = result { + assert!( + ecx.nested_goals.is_empty(), + "Cannot be certain of query response if unevaluated goals exist" + ); } - .evaluate_goal(IsNormalizesToHack::No, goal); assert!(search_graph.is_empty()); result