From 430ee0a57c801187d3488b7eb2039156a0e9c0e3 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Tue, 3 May 2016 13:13:33 -0700 Subject: [PATCH 1/2] Plumb through check_old_skool for expected/found --- src/librustc/infer/error_reporting.rs | 4 ++-- src/libsyntax/errors/mod.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 } From 4ab7bea1b3b1acf1c16e778e6642a76248560625 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Wed, 4 May 2016 11:00:52 -0700 Subject: [PATCH 2/2] Work around issue with test that will be fixed when we move to new errors --- src/test/compile-fail/issue-26480.rs | 4 ++++ 1 file changed, 4 insertions(+) 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!