Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for expected/found not showing in old school mode #33388

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustc/infer/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -554,7 +554,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
"{}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, what I was trying to say before was that if we wanted to have something more like the old output, we could remove the modification below and instead change this line to:

let message = if check_old_skool() {
    format("{} ({})", trace.origin, terr)
} else {
    format("{}", trace.origin)
};
let mut err = struct_span_err!(..., "{}", message);

But I guess I'm ok either way.

trace.origin);

if !is_simple_error {
if !is_simple_error || check_old_skool() {
err = err.note_expected_found(&"type", &expected, &found);
}

Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,13 +691,13 @@ pub fn expect<T, M>(diag: &Handler, opt: Option<T>, 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
}
4 changes: 4 additions & 0 deletions src/test/compile-fail/issue-26480.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
}
}}
}
Expand All @@ -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!
Expand Down