X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_trait_selection%2Fsrc%2Ftraits%2Fchalk_fulfill.rs;h=eed7280ceafcd4606a021a0f834cfd6f9a09251e;hb=f1126f1272d21a5bee1694b5e9bb5f3cf19629d1;hp=ec62ee400688ca2f62cae140fc32b1f40da8bf5e;hpb=11491938f80988c7261a1179cf71a25c379c8783;p=rust.git diff --git a/compiler/rustc_trait_selection/src/traits/chalk_fulfill.rs b/compiler/rustc_trait_selection/src/traits/chalk_fulfill.rs index ec62ee40068..eed7280ceaf 100644 --- a/compiler/rustc_trait_selection/src/traits/chalk_fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/chalk_fulfill.rs @@ -52,31 +52,33 @@ fn register_predicate_obligation( fn select_all_or_error( &mut self, infcx: &InferCtxt<'_, 'tcx>, - ) -> Result<(), Vec>> { - self.select_where_possible(infcx)?; - - if self.obligations.is_empty() { - Ok(()) - } else { - let errors = self - .obligations - .iter() - .map(|obligation| FulfillmentError { - obligation: obligation.clone(), - code: FulfillmentErrorCode::CodeAmbiguity, - // FIXME - does Chalk have a notation of 'root obligation'? - // This is just for diagnostics, so it's okay if this is wrong - root_obligation: obligation.clone(), - }) - .collect(); - Err(errors) + ) -> Vec> { + { + let errors = self.select_where_possible(infcx); + + if !errors.is_empty() { + return errors; + } } + + // any remaining obligations are errors + self + .obligations + .iter() + .map(|obligation| FulfillmentError { + obligation: obligation.clone(), + code: FulfillmentErrorCode::CodeAmbiguity, + // FIXME - does Chalk have a notation of 'root obligation'? + // This is just for diagnostics, so it's okay if this is wrong + root_obligation: obligation.clone(), + }) + .collect() } fn select_where_possible( &mut self, infcx: &InferCtxt<'_, 'tcx>, - ) -> Result<(), Vec>> { + ) -> Vec> { assert!(!infcx.is_in_snapshot()); let mut errors = Vec::new(); @@ -147,7 +149,7 @@ fn select_where_possible( } } - if errors.is_empty() { Ok(()) } else { Err(errors) } + errors } fn pending_obligations(&self) -> Vec> {