diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs index 6273506b8adc7..4e290be31ad49 100644 --- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs @@ -1001,7 +1001,8 @@ where ) -> Result, NoSolutionOrRerunNonErased> { // If this loop did not result in any progress, what's our final certainty. let mut unchanged_certainty = Some(Certainty::Yes); - for (source, goal, stalled_on) in mem::take(&mut self.nested_goals) { + let new_nested_goals = Vec::with_capacity(self.nested_goals.len()); + for (source, goal, stalled_on) in mem::replace(&mut self.nested_goals, new_nested_goals) { // We never handle `NormalizesTo` as a nested goal debug_assert!(!matches!( goal.predicate.kind().skip_binder(),