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;