X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_infer%2Fsrc%2Ftraits%2Fengine.rs;h=f75344f20b6d98e842f622dfd3e39d23e8e22385;hb=a67649675014546ce454d65bc8fe3ebd18e6a319;hp=fcde00056cbf1c4cf4738e80e851497506a05dcf;hpb=82455a799ec408798811d951b9ceb45bdfe57753;p=rust.git diff --git a/compiler/rustc_infer/src/traits/engine.rs b/compiler/rustc_infer/src/traits/engine.rs index fcde00056cb..f75344f20b6 100644 --- a/compiler/rustc_infer/src/traits/engine.rs +++ b/compiler/rustc_infer/src/traits/engine.rs @@ -36,11 +36,19 @@ fn register_predicate_obligation( obligation: PredicateObligation<'tcx>, ); - fn select_all_or_error(&mut self, infcx: &InferCtxt<'tcx>) -> Vec>; - fn select_where_possible(&mut self, infcx: &InferCtxt<'tcx>) -> Vec>; + fn collect_remaining_errors(&mut self) -> Vec>; + fn pending_obligations(&self) -> Vec>; + + /// Among all pending obligations, collect those are stalled on a inference variable which has + /// changed since the last call to `select_where_possible`. Those obligations are marked as + /// successful and returned. + fn drain_unstalled_obligations( + &mut self, + infcx: &InferCtxt<'tcx>, + ) -> Vec>; } pub trait TraitEngineExt<'tcx> { @@ -49,6 +57,8 @@ fn register_predicate_obligations( infcx: &InferCtxt<'tcx>, obligations: impl IntoIterator>, ); + + fn select_all_or_error(&mut self, infcx: &InferCtxt<'tcx>) -> Vec>; } impl<'tcx, T: ?Sized + TraitEngine<'tcx>> TraitEngineExt<'tcx> for T { @@ -61,4 +71,13 @@ fn register_predicate_obligations( self.register_predicate_obligation(infcx, obligation); } } + + fn select_all_or_error(&mut self, infcx: &InferCtxt<'tcx>) -> Vec> { + let errors = self.select_where_possible(infcx); + if !errors.is_empty() { + return errors; + } + + self.collect_remaining_errors() + } }