diff --git a/src/librustc/infer/error_reporting.rs b/src/librustc/infer/error_reporting.rs index 11d92f8585489..dfbc99e01bb60 100644 --- a/src/librustc/infer/error_reporting.rs +++ b/src/librustc/infer/error_reporting.rs @@ -90,7 +90,7 @@ use std::cell::{Cell, RefCell}; use std::char::from_u32; use std::fmt; use syntax::ast; -use syntax::errors::DiagnosticBuilder; +use syntax::errors::{DiagnosticBuilder, check_old_skool}; use syntax::codemap::{self, Pos, Span}; use syntax::parse::token; use syntax::ptr::P; @@ -554,7 +554,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { "{}", trace.origin); - if !is_simple_error { + if !is_simple_error || check_old_skool() { err = err.note_expected_found(&"type", &expected, &found); } diff --git a/src/libsyntax/errors/mod.rs b/src/libsyntax/errors/mod.rs index f0c665bcb3cdb..13a2668ad951a 100644 --- a/src/libsyntax/errors/mod.rs +++ b/src/libsyntax/errors/mod.rs @@ -691,13 +691,13 @@ pub fn expect(diag: &Handler, opt: Option, msg: M) -> T where /// /// FIXME(#33240) #[cfg(not(test))] -fn check_old_skool() -> bool { +pub fn check_old_skool() -> bool { use std::env; env::var("RUST_NEW_ERROR_FORMAT").is_err() } /// For unit tests, use the new format. #[cfg(test)] -fn check_old_skool() -> bool { +pub fn check_old_skool() -> bool { false } diff --git a/src/test/compile-fail/issue-26480.rs b/src/test/compile-fail/issue-26480.rs index adcf8484f7828..c4e18f02a3026 100644 --- a/src/test/compile-fail/issue-26480.rs +++ b/src/test/compile-fail/issue-26480.rs @@ -26,6 +26,8 @@ macro_rules! write { $arr.len() * size_of($arr[0])); //~^ ERROR mismatched types //~| expected u64, found usize + //~| expected type `u64` + //~| found type `usize` } }} } @@ -38,6 +40,8 @@ fn main() { let hello = ['H', 'e', 'y']; write!(hello); //~^ NOTE in this expansion of write! + //~| NOTE in this expansion of write! + //~| NOTE in this expansion of write! cast!(2); //~^ NOTE in this expansion of cast!