From 32133999aee3f47634be5497b14083935e2c38f7 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 26 Jul 2025 00:03:25 +0000 Subject: [PATCH] Don't loop if there are no pending obligations --- compiler/rustc_trait_selection/src/solve/fulfill.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs index 3ce0f02551244..b6d4c2da4923f 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs @@ -118,6 +118,10 @@ impl<'tcx> ObligationStorage<'tcx> { ); }) } + + fn num_pending(&self) -> usize { + self.pending.len() + } } impl<'tcx, E: 'tcx> FulfillmentCtxt<'tcx, E> { @@ -181,6 +185,9 @@ where fn select_where_possible(&mut self, infcx: &InferCtxt<'tcx>) -> Vec { assert_eq!(self.usable_in_snapshot, infcx.num_open_snapshots()); + if self.obligations.num_pending() == 0 { + return vec![]; + } let mut errors = Vec::new(); loop { let mut any_changed = false;