X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc%2Ftraits%2Ferror_reporting.rs;h=047d4bb893096103d38a4f6c3a6af6132ea3133d;hb=dc6b167e224f3a782fa7b1e6f5cff21f5238f97e;hp=3eb45439001cd16298fd037056b8b5819fb5d536;hpb=d92d1935cb01cfa469a725f041e4c1d8a2ee9564;p=rust.git diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 3eb45439001..047d4bb8930 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -24,6 +24,7 @@ SelectionContext, SelectionError, ObjectSafetyViolation, + Overflow, }; use errors::DiagnosticBuilder; @@ -659,8 +660,7 @@ pub fn report_selection_error(&self, predicate: ty::Predicate::Trait(predicate), .. obligation.clone() }; - let mut selcx = SelectionContext::new(self); - if selcx.evaluate_obligation(&unit_obligation) { + if self.predicate_may_hold(&unit_obligation) { err.note("the trait is implemented for `()`. \ Possibly this error has been caused by changes to \ Rust's type-inference algorithm \ @@ -830,6 +830,10 @@ pub fn report_selection_error(&self, } err.struct_error(self.tcx, span, "constant expression") } + + Overflow => { + bug!("overflow should be handled before the `report_selection_error` path"); + } }; self.note_obligation_cause(&mut err, obligation); err.emit(); @@ -872,7 +876,6 @@ fn suggest_remove_reference(&self, .count(); let mut trait_type = trait_ref.self_ty(); - let mut selcx = SelectionContext::new(self); for refs_remaining in 0..refs_number { if let ty::TypeVariants::TyRef(_, ty::TypeAndMut{ ty: t_type, mutbl: _ }) = @@ -886,7 +889,7 @@ fn suggest_remove_reference(&self, obligation.param_env, new_trait_ref.to_predicate()); - if selcx.evaluate_obligation(&new_obligation) { + if self.predicate_may_hold(&new_obligation) { let sp = self.tcx.sess.codemap() .span_take_while(span, |c| c.is_whitespace() || *c == '&'); @@ -1328,7 +1331,7 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { cleaned_pred.to_predicate() ); - selcx.evaluate_obligation(&obligation) + self.predicate_may_hold(&obligation) }) }