diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index d38417143ce..eaa5b6d58f8 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -73,7 +73,7 @@ pub struct InferCtxt<'a, 'tcx: 'a> { // We instantiate UnificationTable with bounds because the // types that might instantiate a general type variable have an // order, represented by its upper and lower bounds. - pub type_variables: RefCell>, + type_variables: RefCell>, // Map from integral variable to the kind of integer it represents int_unification_table: RefCell>, @@ -1366,19 +1366,19 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } pub fn report_conflicting_default_types(&self, - span: Span, - expected: type_variable::Default<'tcx>, - actual: type_variable::Default<'tcx>) { + span: Span, + expected: type_variable::Default<'tcx>, + actual: type_variable::Default<'tcx>) { let trace = TypeTrace { origin: Misc(span), - values: Types(ty::expected_found { + values: Types(ty::ExpectedFound { expected: expected.ty, found: actual.ty }) }; self.report_and_explain_type_error(trace, - &ty::type_err::terr_ty_param_default_mismatch(ty::expected_found { + &TypeError::TyParamDefaultMismatch(ty::ExpectedFound { expected: expected, found: actual })); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 19add679bbf..4945e0766e7 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2039,7 +2039,7 @@ pub struct ExpectedFound { } // Data structures used in type unification -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Debug)] pub enum TypeError<'tcx> { Mismatch, UnsafetyMismatch(ExpectedFound), @@ -2069,7 +2069,7 @@ pub enum TypeError<'tcx> { ConvergenceMismatch(ExpectedFound), ProjectionNameMismatched(ExpectedFound), ProjectionBoundsLength(ExpectedFound), - TyParamDefaultMismatch(ExpectedFound>) + TyParamDefaultMismatch(ExpectedFound>) } /// Bounds suitable for an existentially quantified type parameter @@ -5083,7 +5083,7 @@ impl<'tcx> fmt::Display for TypeError<'tcx> { values.expected, values.found) }, - terr_ty_param_default_mismatch(ref values) => { + TyParamDefaultMismatch(ref values) => { write!(f, "conflicting type parameter defaults {} and {}", values.expected.ty, values.found.ty) @@ -5445,7 +5445,7 @@ impl<'tcx> ctxt<'tcx> { using it as a trait object")); } }, - terr_ty_param_default_mismatch(values) => { + TyParamDefaultMismatch(values) => { let expected = values.expected; let found = values.found; self.sess.span_note(sp, diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index d93848f408c..c9b10cec44a 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1785,7 +1785,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // it had been solved by previously applying a default. // We take a snapshot for use in error reporting. - let snapshot = self.infcx().type_variables.borrow_mut().snapshot(); + let snapshot = self.infcx().start_snapshot(); for ty in &unbound_tyvars { if self.infcx().type_var_diverges(ty) { @@ -1815,10 +1815,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - // There were some errors to report + // There are some errors to report if conflicts.len() > 0 { - self.infcx().type_variables.borrow_mut().rollback_to(snapshot); + self.infcx().rollback_to(snapshot); + // Loop through each conflicting default compute the conflict + // and then report the error. for (conflict, default) in conflicts { let conflicting_default = self.find_conflicting_default( @@ -1836,7 +1838,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { default) } } else { - self.infcx().type_variables.borrow_mut().commit(snapshot) + self.infcx().commit_from(snapshot) } }