From c73bcf043e94b32e2d53ecfd3e53a0535b320456 Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Thu, 26 Oct 2017 04:39:37 +0000 Subject: [PATCH 1/7] show macro backtrace with env var --- src/librustc_errors/emitter.rs | 59 ++++++++++++++++++++++++++-------- src/librustc_errors/snippet.rs | 1 + 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 57523d2c058dc..7ce902d0a6f60 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -23,6 +23,7 @@ use std::rc::Rc; use term; use std::collections::HashMap; use std::cmp::min; +use std::env; /// Emitter trait for emitting errors. pub trait Emitter { @@ -786,18 +787,20 @@ impl EmitterWriter { fn fix_multispans_in_std_macros(&mut self, span: &mut MultiSpan, children: &mut Vec) { - let mut spans_updated = self.fix_multispan_in_std_macros(span); - for child in children.iter_mut() { - spans_updated |= self.fix_multispan_in_std_macros(&mut child.span); - } - if spans_updated { - children.push(SubDiagnostic { - level: Level::Note, - message: vec![("this error originates in a macro outside of the current crate" - .to_string(), Style::NoStyle)], - span: MultiSpan::new(), - render_span: None, - }); + if env::var_os("RUST_MACRO_BACKTRACE").is_none() { + let mut spans_updated = self.fix_multispan_in_std_macros(span); + for child in children.iter_mut() { + spans_updated |= self.fix_multispan_in_std_macros(&mut child.span); + } + if spans_updated { + children.push(SubDiagnostic { + level: Level::Note, + message: vec![("this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info)" + .to_string(), Style::NoStyle)], + span: MultiSpan::new(), + render_span: None, + }); + } } } @@ -1079,6 +1082,12 @@ impl EmitterWriter { } } + if env::var_os("RUST_MACRO_BACKTRACE").is_some() { + if let Some(ref primary_span) = msp.primary_span().as_ref() { + self.render_macro_backtrace_old_school(primary_span, &mut buffer)?; + } + } + // final step: take our styled buffer, render it, then output it emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?; @@ -1226,6 +1235,30 @@ impl EmitterWriter { } } } + + fn render_macro_backtrace_old_school(&self, + sp: &Span, + buffer: &mut StyledBuffer) -> io::Result<()> { + if let Some(ref cm) = self.cm { + for trace in sp.macro_backtrace().iter().rev() { + let line_offset = buffer.num_lines(); + + let mut diag_string = + format!("in this expansion of {}", trace.macro_decl_name); + if let Some(def_site_span) = trace.def_site_span { + diag_string.push_str( + &format!(" (defined in {})", + cm.span_to_filename(def_site_span))); + } + let snippet = cm.span_to_string(trace.call_site); + buffer.append(line_offset, &format!("{} ", snippet), Style::NoStyle); + buffer.append(line_offset, "note", Style::Level(Level::Note)); + buffer.append(line_offset, ": ", Style::NoStyle); + buffer.append(line_offset, &diag_string, Style::OldSchoolNoteText); + } + } + Ok(()) + } } fn draw_col_separator(buffer: &mut StyledBuffer, line: usize, col: usize) { @@ -1415,7 +1448,7 @@ impl Destination { } } Style::Quotation => {} - Style::HeaderMsg => { + Style::OldSchoolNoteText | Style::HeaderMsg => { self.start_attr(term::Attr::Bold)?; if cfg!(windows) { self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_WHITE))?; diff --git a/src/librustc_errors/snippet.rs b/src/librustc_errors/snippet.rs index 2e8deeee5a599..b76036b22df53 100644 --- a/src/librustc_errors/snippet.rs +++ b/src/librustc_errors/snippet.rs @@ -213,6 +213,7 @@ pub enum Style { UnderlineSecondary, LabelPrimary, LabelSecondary, + OldSchoolNoteText, NoStyle, Level(Level), Highlight, From bcd1fedf034b8735605b390f3a4d75b65162b514 Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Fri, 27 Oct 2017 04:50:54 +0000 Subject: [PATCH 2/7] add UI test --- src/librustc_errors/emitter.rs | 9 ++++--- src/test/ui/macro_backtrace/auxiliary/ping.rs | 20 +++++++++++++++ src/test/ui/macro_backtrace/main.rs | 25 +++++++++++++++++++ src/test/ui/macro_backtrace/main.stderr | 21 ++++++++++++++++ 4 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 src/test/ui/macro_backtrace/auxiliary/ping.rs create mode 100644 src/test/ui/macro_backtrace/main.rs create mode 100644 src/test/ui/macro_backtrace/main.stderr diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 7ce902d0a6f60..41672d8948613 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -795,8 +795,11 @@ impl EmitterWriter { if spans_updated { children.push(SubDiagnostic { level: Level::Note, - message: vec![("this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info)" - .to_string(), Style::NoStyle)], + message: vec![ + (["this error originates in a macro outside of the current crate", + "(run with RUST_MACRO_BACKTRACE=1 for more info)"].join(" "), + Style::NoStyle), + ], span: MultiSpan::new(), render_span: None, }); @@ -1242,7 +1245,7 @@ impl EmitterWriter { if let Some(ref cm) = self.cm { for trace in sp.macro_backtrace().iter().rev() { let line_offset = buffer.num_lines(); - + let mut diag_string = format!("in this expansion of {}", trace.macro_decl_name); if let Some(def_site_span) = trace.def_site_span { diff --git a/src/test/ui/macro_backtrace/auxiliary/ping.rs b/src/test/ui/macro_backtrace/auxiliary/ping.rs new file mode 100644 index 0000000000000..eeed0d78158c8 --- /dev/null +++ b/src/test/ui/macro_backtrace/auxiliary/ping.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the macro backtrace facility works (supporting file) + +// a non-local macro +#[macro_export] +macro_rules! ping { + () => { + pong!(); + } +} + diff --git a/src/test/ui/macro_backtrace/main.rs b/src/test/ui/macro_backtrace/main.rs new file mode 100644 index 0000000000000..4da0c586d6008 --- /dev/null +++ b/src/test/ui/macro_backtrace/main.rs @@ -0,0 +1,25 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the macro backtrace facility works +// aux-build:ping.rs +// rustc-env:RUST_MACRO_BACKTRACE + +#[macro_use] extern crate ping; + +// a local macro +macro_rules! pong { + () => { syntax error }; +} + +fn main() { + pong!(); + ping!(); +} diff --git a/src/test/ui/macro_backtrace/main.stderr b/src/test/ui/macro_backtrace/main.stderr new file mode 100644 index 0000000000000..37f3d45021572 --- /dev/null +++ b/src/test/ui/macro_backtrace/main.stderr @@ -0,0 +1,21 @@ +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `error` + --> $DIR/main.rs:19:20 + | +19 | () => { syntax error }; + | -^^^^^ unexpected token + | | + | expected one of 8 possible tokens here +$DIR/main.rs:23:5: 23:13 note: in this expansion of pong! (defined in $DIR/main.rs) + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `error` + --> $DIR/main.rs:19:20 + | +19 | () => { syntax error }; + | -^^^^^ unexpected token + | | + | expected one of 8 possible tokens here +$DIR/main.rs:24:5: 24:13 note: in this expansion of ping! (defined in ) +:1:11: 1:24 note: in this expansion of pong! (defined in $DIR/main.rs) + +error: aborting due to 2 previous errors + From bec62c2f12a4c13000d0c7647a6a43ed3ae95785 Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Fri, 27 Oct 2017 12:32:23 +0000 Subject: [PATCH 3/7] update UI tests --- src/test/ui/codemap_tests/bad-format-args.stderr | 6 +++--- src/test/ui/codemap_tests/issue-28308.stderr | 2 +- src/test/ui/cross-crate-macro-backtrace/main.stderr | 2 +- src/test/ui/fmt/format-string-error.stderr | 4 ++-- src/test/ui/lifetimes/borrowck-let-suggestion.stderr | 2 +- src/test/ui/macros/format-foreign.stderr | 2 +- src/test/ui/macros/format-unused-lables.stderr | 6 +++--- src/test/ui/reachable/expr_again.stderr | 2 +- src/test/ui/reachable/expr_block.stderr | 2 +- src/test/ui/reachable/expr_if.stderr | 2 +- src/test/ui/reachable/expr_loop.stderr | 6 +++--- src/test/ui/reachable/expr_match.stderr | 4 ++-- src/test/ui/reachable/expr_while.stderr | 6 +++--- src/test/ui/span/coerce-suggestions.stderr | 2 +- src/test/ui/span/issue-33884.stderr | 2 +- src/test/ui/span/issue-40157.stderr | 2 +- src/test/ui/span/slice-borrow.stderr | 2 +- src/test/ui/type-check/cannot_infer_local_or_vec.stderr | 2 +- .../type-check/cannot_infer_local_or_vec_in_tuples.stderr | 2 +- 19 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/test/ui/codemap_tests/bad-format-args.stderr b/src/test/ui/codemap_tests/bad-format-args.stderr index 87255dfe77476..258c0f228bef3 100644 --- a/src/test/ui/codemap_tests/bad-format-args.stderr +++ b/src/test/ui/codemap_tests/bad-format-args.stderr @@ -4,7 +4,7 @@ error: requires at least a format string argument 12 | format!(); | ^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: expected token: `,` --> $DIR/bad-format-args.rs:13:5 @@ -12,7 +12,7 @@ error: expected token: `,` 13 | format!("" 1); | ^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: expected token: `,` --> $DIR/bad-format-args.rs:14:5 @@ -20,7 +20,7 @@ error: expected token: `,` 14 | format!("", 1 1); | ^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/codemap_tests/issue-28308.stderr b/src/test/ui/codemap_tests/issue-28308.stderr index 7a1478104fdf1..cecf9eab6576d 100644 --- a/src/test/ui/codemap_tests/issue-28308.stderr +++ b/src/test/ui/codemap_tests/issue-28308.stderr @@ -4,7 +4,7 @@ error[E0600]: cannot apply unary operator `!` to type `&'static str` 12 | assert!("foo"); | ^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: aborting due to previous error diff --git a/src/test/ui/cross-crate-macro-backtrace/main.stderr b/src/test/ui/cross-crate-macro-backtrace/main.stderr index 4dad6d60b402e..55395c4fc4b2c 100644 --- a/src/test/ui/cross-crate-macro-backtrace/main.stderr +++ b/src/test/ui/cross-crate-macro-backtrace/main.stderr @@ -4,7 +4,7 @@ error: 1 positional argument in format string, but no arguments were given 16 | myprintln!("{}"); //~ ERROR in this macro | ^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: aborting due to previous error diff --git a/src/test/ui/fmt/format-string-error.stderr b/src/test/ui/fmt/format-string-error.stderr index 58b392f0b8d65..96f646a7fb179 100644 --- a/src/test/ui/fmt/format-string-error.stderr +++ b/src/test/ui/fmt/format-string-error.stderr @@ -5,7 +5,7 @@ error: invalid format string: expected `'}'` but string was terminated | ^^^^^^^^^^^^^^ | = note: if you intended to print `{`, you can escape it using `{{` - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: invalid format string: unmatched `}` found --> $DIR/format-string-error.rs:14:5 @@ -14,7 +14,7 @@ error: invalid format string: unmatched `}` found | ^^^^^^^^^^^^^^ | = note: if you intended to print `}`, you can escape it using `}}` - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/lifetimes/borrowck-let-suggestion.stderr b/src/test/ui/lifetimes/borrowck-let-suggestion.stderr index 6316c06666003..bd717b1b6e513 100644 --- a/src/test/ui/lifetimes/borrowck-let-suggestion.stderr +++ b/src/test/ui/lifetimes/borrowck-let-suggestion.stderr @@ -9,7 +9,7 @@ error[E0597]: borrowed value does not live long enough | - temporary value needs to live until here | = note: consider using a `let` binding to increase its lifetime - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: aborting due to previous error diff --git a/src/test/ui/macros/format-foreign.stderr b/src/test/ui/macros/format-foreign.stderr index 00469b5f7998c..f6412cae44ac7 100644 --- a/src/test/ui/macros/format-foreign.stderr +++ b/src/test/ui/macros/format-foreign.stderr @@ -11,7 +11,7 @@ error: multiple unused formatting arguments = help: `%.*3$s` should be written as `{:.2$}` = help: `%s` should be written as `{}` = note: printf formatting not supported; see the documentation for `std::fmt` - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: argument never used --> $DIR/format-foreign.rs:13:29 diff --git a/src/test/ui/macros/format-unused-lables.stderr b/src/test/ui/macros/format-unused-lables.stderr index bd6d38ccb0a44..33d9889d127f5 100644 --- a/src/test/ui/macros/format-unused-lables.stderr +++ b/src/test/ui/macros/format-unused-lables.stderr @@ -8,7 +8,7 @@ error: multiple unused formatting arguments | | unused | unused | - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: multiple unused formatting arguments --> $DIR/format-unused-lables.rs:14:5 @@ -23,7 +23,7 @@ error: multiple unused formatting arguments 18 | | ); | |______^ | - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: named argument never used --> $DIR/format-unused-lables.rs:20:35 @@ -47,7 +47,7 @@ error: multiple unused formatting arguments | = help: `$STUFF` should be written as `{STUFF}` = note: shell formatting not supported; see the documentation for `std::fmt` - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: aborting due to 4 previous errors diff --git a/src/test/ui/reachable/expr_again.stderr b/src/test/ui/reachable/expr_again.stderr index bf4e4dc4711cb..fdc309ed99961 100644 --- a/src/test/ui/reachable/expr_again.stderr +++ b/src/test/ui/reachable/expr_again.stderr @@ -9,7 +9,7 @@ note: lint level defined here | 13 | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: aborting due to previous error diff --git a/src/test/ui/reachable/expr_block.stderr b/src/test/ui/reachable/expr_block.stderr index 542ce1c3fd9cb..1c03c26609c6a 100644 --- a/src/test/ui/reachable/expr_block.stderr +++ b/src/test/ui/reachable/expr_block.stderr @@ -16,7 +16,7 @@ error: unreachable statement 36 | println!("foo"); | ^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/reachable/expr_if.stderr b/src/test/ui/reachable/expr_if.stderr index 2cf17474f6e9d..bb5acd4b14332 100644 --- a/src/test/ui/reachable/expr_if.stderr +++ b/src/test/ui/reachable/expr_if.stderr @@ -9,7 +9,7 @@ note: lint level defined here | 14 | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: aborting due to previous error diff --git a/src/test/ui/reachable/expr_loop.stderr b/src/test/ui/reachable/expr_loop.stderr index 6e98e754c54db..e1f1f9a5fb4db 100644 --- a/src/test/ui/reachable/expr_loop.stderr +++ b/src/test/ui/reachable/expr_loop.stderr @@ -9,7 +9,7 @@ note: lint level defined here | 14 | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: unreachable statement --> $DIR/expr_loop.rs:31:5 @@ -17,7 +17,7 @@ error: unreachable statement 31 | println!("I am dead."); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: unreachable statement --> $DIR/expr_loop.rs:41:5 @@ -25,7 +25,7 @@ error: unreachable statement 41 | println!("I am dead."); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/reachable/expr_match.stderr b/src/test/ui/reachable/expr_match.stderr index f5857a5b345ec..585d036731185 100644 --- a/src/test/ui/reachable/expr_match.stderr +++ b/src/test/ui/reachable/expr_match.stderr @@ -16,7 +16,7 @@ error: unreachable statement 25 | println!("I am dead"); | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: unreachable statement --> $DIR/expr_match.rs:35:5 @@ -24,7 +24,7 @@ error: unreachable statement 35 | println!("I am dead"); | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/reachable/expr_while.stderr b/src/test/ui/reachable/expr_while.stderr index 066cfc86c6462..87d1ac97712a7 100644 --- a/src/test/ui/reachable/expr_while.stderr +++ b/src/test/ui/reachable/expr_while.stderr @@ -9,7 +9,7 @@ note: lint level defined here | 14 | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: unreachable statement --> $DIR/expr_while.rs:33:9 @@ -17,7 +17,7 @@ error: unreachable statement 33 | println!("I am dead."); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: unreachable statement --> $DIR/expr_while.rs:35:5 @@ -25,7 +25,7 @@ error: unreachable statement 35 | println!("I am, too."); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/span/coerce-suggestions.stderr b/src/test/ui/span/coerce-suggestions.stderr index b703632bf90c1..9a43a869b6020 100644 --- a/src/test/ui/span/coerce-suggestions.stderr +++ b/src/test/ui/span/coerce-suggestions.stderr @@ -56,7 +56,7 @@ error[E0308]: mismatched types = note: expected type `&mut std::string::String` found type `std::string::String` = help: try with `&mut format!("foo")` - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: aborting due to 6 previous errors diff --git a/src/test/ui/span/issue-33884.stderr b/src/test/ui/span/issue-33884.stderr index 2a874181c7ad9..38515268c733d 100644 --- a/src/test/ui/span/issue-33884.stderr +++ b/src/test/ui/span/issue-33884.stderr @@ -6,7 +6,7 @@ error[E0308]: mismatched types | = note: expected type `std::fmt::Arguments<'_>` found type `std::string::String` - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: aborting due to previous error diff --git a/src/test/ui/span/issue-40157.stderr b/src/test/ui/span/issue-40157.stderr index b689bef63f156..4826410de30e5 100644 --- a/src/test/ui/span/issue-40157.stderr +++ b/src/test/ui/span/issue-40157.stderr @@ -8,7 +8,7 @@ error[E0597]: `foo` does not live long enough | | borrow occurs here | borrowed value needs to live until here | - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: aborting due to previous error diff --git a/src/test/ui/span/slice-borrow.stderr b/src/test/ui/span/slice-borrow.stderr index 5e8edf80df69e..679cba9f59c4e 100644 --- a/src/test/ui/span/slice-borrow.stderr +++ b/src/test/ui/span/slice-borrow.stderr @@ -9,7 +9,7 @@ error[E0597]: borrowed value does not live long enough 19 | } | - temporary value needs to live until here | - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: aborting due to previous error diff --git a/src/test/ui/type-check/cannot_infer_local_or_vec.stderr b/src/test/ui/type-check/cannot_infer_local_or_vec.stderr index 4788fad20889e..06550634cc818 100644 --- a/src/test/ui/type-check/cannot_infer_local_or_vec.stderr +++ b/src/test/ui/type-check/cannot_infer_local_or_vec.stderr @@ -6,7 +6,7 @@ error[E0282]: type annotations needed | | | consider giving `x` a type | - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: aborting due to previous error diff --git a/src/test/ui/type-check/cannot_infer_local_or_vec_in_tuples.stderr b/src/test/ui/type-check/cannot_infer_local_or_vec_in_tuples.stderr index ccffadebe9ee2..8ec68b6133aa5 100644 --- a/src/test/ui/type-check/cannot_infer_local_or_vec_in_tuples.stderr +++ b/src/test/ui/type-check/cannot_infer_local_or_vec_in_tuples.stderr @@ -6,7 +6,7 @@ error[E0282]: type annotations needed | | | consider giving the pattern a type | - = note: this error originates in a macro outside of the current crate + = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) error: aborting due to previous error From 7a5a1f98572887d9642c7321be6c0d5abf7aaffb Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Sat, 18 Nov 2017 20:16:10 +0000 Subject: [PATCH 4/7] use -Z flag instead of env var --- src/librustc/session/config.rs | 2 + src/librustc/session/mod.rs | 7 ++- src/librustc_driver/lib.rs | 4 +- src/librustc_driver/test.rs | 2 +- src/librustc_errors/diagnostic_builder.rs | 2 +- src/librustc_errors/emitter.rs | 51 +++++++++++-------- src/librustc_errors/lib.rs | 6 ++- src/librustc_trans/back/write.rs | 2 +- src/librustdoc/core.rs | 1 + src/librustdoc/test.rs | 4 +- src/libsyntax/parse/lexer/mod.rs | 2 +- src/libsyntax/parse/mod.rs | 1 + src/libsyntax/test_snippet.rs | 2 +- .../ui/codemap_tests/bad-format-args.stderr | 6 +-- src/test/ui/codemap_tests/issue-28308.stderr | 2 +- .../cross-crate-macro-backtrace/main.stderr | 2 +- src/test/ui/fmt/format-string-error.stderr | 4 +- .../lifetimes/borrowck-let-suggestion.stderr | 2 +- src/test/ui/macro_backtrace/main.rs | 2 +- src/test/ui/macros/format-foreign.stderr | 2 +- .../ui/macros/format-unused-lables.stderr | 6 +-- src/test/ui/reachable/expr_again.stderr | 2 +- src/test/ui/reachable/expr_block.stderr | 2 +- src/test/ui/reachable/expr_if.stderr | 2 +- src/test/ui/reachable/expr_loop.stderr | 6 +-- src/test/ui/reachable/expr_match.stderr | 4 +- src/test/ui/reachable/expr_while.stderr | 6 +-- src/test/ui/span/coerce-suggestions.stderr | 2 +- src/test/ui/span/issue-33884.stderr | 2 +- src/test/ui/span/issue-40157.stderr | 2 +- src/test/ui/span/slice-borrow.stderr | 2 +- .../cannot_infer_local_or_vec.stderr | 2 +- ...cannot_infer_local_or_vec_in_tuples.stderr | 2 +- 33 files changed, 83 insertions(+), 63 deletions(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 57fae2200e276..25123acdc674f 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1036,6 +1036,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "run all passes except translation; no output"), treat_err_as_bug: bool = (false, parse_bool, [TRACKED], "treat all errors that occur as bugs"), + macro_backtrace: bool = (false, parse_bool, [UNTRACKED], + "show macro backtraces even for foreign macros"), continue_parse_after_error: bool = (false, parse_bool, [TRACKED], "attempt to recover from parse errors (experimental)"), incremental: Option = (None, parse_opt_string, [UNTRACKED], diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 00a91eeb9c18e..ab270648f3a2f 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -731,6 +731,8 @@ pub fn build_session_with_codemap(sopts: config::Options, let treat_err_as_bug = sopts.debugging_opts.treat_err_as_bug; + let macro_backtrace = sopts.debugging_opts.macro_backtrace; + let emitter: Box = match (sopts.error_format, emitter_dest) { (config::ErrorOutputType::HumanReadable(color_config), None) => { Box::new(EmitterWriter::stderr(color_config, Some(codemap.clone()), false)) @@ -755,6 +757,7 @@ pub fn build_session_with_codemap(sopts: config::Options, let diagnostic_handler = errors::Handler::with_emitter(can_print_warnings, treat_err_as_bug, + macro_backtrace, emitter); build_session_(sopts, @@ -925,7 +928,7 @@ pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! { Box::new(EmitterWriter::stderr(color_config, None, true)) } }; - let handler = errors::Handler::with_emitter(true, false, emitter); + let handler = errors::Handler::with_emitter(true, false, false, emitter); handler.emit(&MultiSpan::new(), msg, errors::Level::Fatal); panic!(errors::FatalError); } @@ -940,7 +943,7 @@ pub fn early_warn(output: config::ErrorOutputType, msg: &str) { Box::new(EmitterWriter::stderr(color_config, None, true)) } }; - let handler = errors::Handler::with_emitter(true, false, emitter); + let handler = errors::Handler::with_emitter(true, false, false, emitter); handler.emit(&MultiSpan::new(), msg, errors::Level::Warning); } diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index c5cce70c94566..2f847e3dd97eb 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -141,7 +141,7 @@ pub fn run(run_compiler: F) -> isize errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto, None, true); - let handler = errors::Handler::with_emitter(true, false, Box::new(emitter)); + let handler = errors::Handler::with_emitter(true, false, false, Box::new(emitter)); handler.emit(&MultiSpan::new(), "aborting due to previous error(s)", errors::Level::Fatal); @@ -1221,7 +1221,7 @@ pub fn monitor(f: F) { Box::new(errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto, None, false)); - let handler = errors::Handler::with_emitter(true, false, emitter); + let handler = errors::Handler::with_emitter(true, false, false, emitter); // a .span_bug or .bug call has already printed what // it wants to print. diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 78ce959e5c94e..8a4cc2378052e 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -104,7 +104,7 @@ fn test_env(source_string: &str, let mut options = config::basic_options(); options.debugging_opts.verbose = true; options.unstable_features = UnstableFeatures::Allow; - let diagnostic_handler = errors::Handler::with_emitter(true, false, emitter); + let diagnostic_handler = errors::Handler::with_emitter(true, false, false, emitter); let cstore = Rc::new(CStore::new(::DefaultTransCrate::metadata_loader())); let sess = session::build_session_(options, diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index 40b5810454b9a..27e895164e764 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -23,7 +23,7 @@ use syntax_pos::{MultiSpan, Span}; #[must_use] #[derive(Clone)] pub struct DiagnosticBuilder<'a> { - handler: &'a Handler, + pub handler: &'a Handler, diagnostic: Diagnostic, } diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 41672d8948613..f3f5b443a4306 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -23,7 +23,6 @@ use std::rc::Rc; use term; use std::collections::HashMap; use std::cmp::min; -use std::env; /// Emitter trait for emitting errors. pub trait Emitter { @@ -65,8 +64,11 @@ impl Emitter for EmitterWriter { } } - self.fix_multispans_in_std_macros(&mut primary_span, &mut children); + if !db.handler.macro_backtrace { + self.fix_multispans_in_std_macros(&mut primary_span, &mut children); + } self.emit_messages_default(&db.level, + db.handler.macro_backtrace, &db.styled_message(), &db.code, &primary_span, @@ -787,23 +789,21 @@ impl EmitterWriter { fn fix_multispans_in_std_macros(&mut self, span: &mut MultiSpan, children: &mut Vec) { - if env::var_os("RUST_MACRO_BACKTRACE").is_none() { - let mut spans_updated = self.fix_multispan_in_std_macros(span); - for child in children.iter_mut() { - spans_updated |= self.fix_multispan_in_std_macros(&mut child.span); - } - if spans_updated { - children.push(SubDiagnostic { - level: Level::Note, - message: vec![ - (["this error originates in a macro outside of the current crate", - "(run with RUST_MACRO_BACKTRACE=1 for more info)"].join(" "), - Style::NoStyle), - ], - span: MultiSpan::new(), - render_span: None, - }); - } + let mut spans_updated = self.fix_multispan_in_std_macros(span); + for child in children.iter_mut() { + spans_updated |= self.fix_multispan_in_std_macros(&mut child.span); + } + if spans_updated { + children.push(SubDiagnostic { + level: Level::Note, + message: vec![ + (["this error originates in a macro outside of the current crate", + "(run with -Z macro-backtrace for more info)"].join(" "), + Style::NoStyle), + ], + span: MultiSpan::new(), + render_span: None, + }); } } @@ -888,6 +888,7 @@ impl EmitterWriter { msg: &Vec<(String, Style)>, code: &Option, level: &Level, + macro_backtrace: bool, max_line_num_len: usize, is_secondary: bool) -> io::Result<()> { @@ -1085,7 +1086,7 @@ impl EmitterWriter { } } - if env::var_os("RUST_MACRO_BACKTRACE").is_some() { + if macro_backtrace { if let Some(ref primary_span) = msp.primary_span().as_ref() { self.render_macro_backtrace_old_school(primary_span, &mut buffer)?; } @@ -1182,6 +1183,7 @@ impl EmitterWriter { } fn emit_messages_default(&mut self, level: &Level, + macro_backtrace: bool, message: &Vec<(String, Style)>, code: &Option, span: &MultiSpan, @@ -1190,7 +1192,13 @@ impl EmitterWriter { let max_line_num = self.get_max_line_num(span, children); let max_line_num_len = max_line_num.to_string().len(); - match self.emit_message_default(span, message, code, level, max_line_num_len, false) { + match self.emit_message_default(span, + message, + code, + level, + macro_backtrace, + max_line_num_len, + false) { Ok(()) => { if !children.is_empty() { let mut buffer = StyledBuffer::new(); @@ -1210,6 +1218,7 @@ impl EmitterWriter { &child.styled_message(), &None, &child.level, + macro_backtrace, max_line_num_len, true) { Err(e) => panic!("failed to emit error: {}", e), diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index e83ac8831de25..99d94aaf912a0 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -237,6 +237,7 @@ pub struct Handler { emitter: RefCell>, pub can_emit_warnings: bool, treat_err_as_bug: bool, + pub macro_backtrace: bool, continue_after_error: Cell, delayed_span_bug: RefCell>, tracked_diagnostics: RefCell>>, @@ -251,14 +252,16 @@ impl Handler { pub fn with_tty_emitter(color_config: ColorConfig, can_emit_warnings: bool, treat_err_as_bug: bool, + macro_backtrace: bool, cm: Option>) -> Handler { let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false)); - Handler::with_emitter(can_emit_warnings, treat_err_as_bug, emitter) + Handler::with_emitter(can_emit_warnings, treat_err_as_bug, macro_backtrace, emitter) } pub fn with_emitter(can_emit_warnings: bool, treat_err_as_bug: bool, + macro_backtrace: bool, e: Box) -> Handler { Handler { @@ -266,6 +269,7 @@ impl Handler { emitter: RefCell::new(e), can_emit_warnings, treat_err_as_bug, + macro_backtrace, continue_after_error: Cell::new(true), delayed_span_bug: RefCell::new(None), tracked_diagnostics: RefCell::new(None), diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index e443f13a7a1ca..180a2f4ed6c6d 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -353,7 +353,7 @@ pub struct CodegenContext { impl CodegenContext { pub fn create_diag_handler(&self) -> Handler { - Handler::with_emitter(true, false, Box::new(self.diag_emitter.clone())) + Handler::with_emitter(true, false, false, Box::new(self.diag_emitter.clone())) } pub fn config(&self, kind: ModuleKind) -> &ModuleConfig { diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 9172bfcde3f9e..8db6cb51ce4a1 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -141,6 +141,7 @@ pub fn run_core(search_paths: SearchPaths, let diagnostic_handler = errors::Handler::with_tty_emitter(ColorConfig::Auto, true, false, + false, Some(codemap.clone())); let cstore = Rc::new(CStore::new(box rustc_trans::LlvmMetadataLoader)); diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 9bbd16355be38..03cb77422cf5c 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -81,7 +81,7 @@ pub fn run(input: &str, let codemap = Rc::new(CodeMap::new(sessopts.file_path_mapping())); let handler = - errors::Handler::with_tty_emitter(ColorConfig::Auto, true, false, Some(codemap.clone())); + errors::Handler::with_tty_emitter(ColorConfig::Auto, true, false, false, Some(codemap.clone())); let cstore = Rc::new(CStore::new(box rustc_trans::LlvmMetadataLoader)); let mut sess = session::build_session_( @@ -244,7 +244,7 @@ fn run_test(test: &str, cratename: &str, filename: &str, cfgs: Vec, libs let _bomb = Bomb(data.clone(), old.unwrap_or(box io::stdout())); // Compile the code - let diagnostic_handler = errors::Handler::with_emitter(true, false, box emitter); + let diagnostic_handler = errors::Handler::with_emitter(true, false, false, box emitter); let cstore = Rc::new(CStore::new(box rustc_trans::LlvmMetadataLoader)); let mut sess = session::build_session_( diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 951163d35fa0f..924183fd64e0e 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1726,7 +1726,7 @@ mod tests { Some(cm.clone()), false); ParseSess { - span_diagnostic: errors::Handler::with_emitter(true, false, Box::new(emitter)), + span_diagnostic: errors::Handler::with_emitter(true, false, false, Box::new(emitter)), unstable_features: UnstableFeatures::from_environment(), config: CrateConfig::new(), included_mod_stack: RefCell::new(Vec::new()), diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index c679efd41ea46..11e4abdb3501f 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -58,6 +58,7 @@ impl ParseSess { let handler = Handler::with_tty_emitter(ColorConfig::Auto, true, false, + false, Some(cm.clone())); ParseSess::with_span_handler(handler, cm) } diff --git a/src/libsyntax/test_snippet.rs b/src/libsyntax/test_snippet.rs index a29250ea5f19f..10ad440ca8580 100644 --- a/src/libsyntax/test_snippet.rs +++ b/src/libsyntax/test_snippet.rs @@ -62,7 +62,7 @@ fn test_harness(file_text: &str, span_labels: Vec, expected_output: & let emitter = EmitterWriter::new(Box::new(Shared { data: output.clone() }), Some(code_map.clone()), false); - let handler = Handler::with_emitter(true, false, Box::new(emitter)); + let handler = Handler::with_emitter(true, false, false, Box::new(emitter)); handler.span_err(msp, "foo"); assert!(expected_output.chars().next() == Some('\n'), diff --git a/src/test/ui/codemap_tests/bad-format-args.stderr b/src/test/ui/codemap_tests/bad-format-args.stderr index 258c0f228bef3..ba7e88103f5c6 100644 --- a/src/test/ui/codemap_tests/bad-format-args.stderr +++ b/src/test/ui/codemap_tests/bad-format-args.stderr @@ -4,7 +4,7 @@ error: requires at least a format string argument 12 | format!(); | ^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: expected token: `,` --> $DIR/bad-format-args.rs:13:5 @@ -12,7 +12,7 @@ error: expected token: `,` 13 | format!("" 1); | ^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: expected token: `,` --> $DIR/bad-format-args.rs:14:5 @@ -20,7 +20,7 @@ error: expected token: `,` 14 | format!("", 1 1); | ^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/codemap_tests/issue-28308.stderr b/src/test/ui/codemap_tests/issue-28308.stderr index cecf9eab6576d..a065e06926b50 100644 --- a/src/test/ui/codemap_tests/issue-28308.stderr +++ b/src/test/ui/codemap_tests/issue-28308.stderr @@ -4,7 +4,7 @@ error[E0600]: cannot apply unary operator `!` to type `&'static str` 12 | assert!("foo"); | ^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/cross-crate-macro-backtrace/main.stderr b/src/test/ui/cross-crate-macro-backtrace/main.stderr index 55395c4fc4b2c..a6e589160a53a 100644 --- a/src/test/ui/cross-crate-macro-backtrace/main.stderr +++ b/src/test/ui/cross-crate-macro-backtrace/main.stderr @@ -4,7 +4,7 @@ error: 1 positional argument in format string, but no arguments were given 16 | myprintln!("{}"); //~ ERROR in this macro | ^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/fmt/format-string-error.stderr b/src/test/ui/fmt/format-string-error.stderr index 96f646a7fb179..9d45c84c03c86 100644 --- a/src/test/ui/fmt/format-string-error.stderr +++ b/src/test/ui/fmt/format-string-error.stderr @@ -5,7 +5,7 @@ error: invalid format string: expected `'}'` but string was terminated | ^^^^^^^^^^^^^^ | = note: if you intended to print `{`, you can escape it using `{{` - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: invalid format string: unmatched `}` found --> $DIR/format-string-error.rs:14:5 @@ -14,7 +14,7 @@ error: invalid format string: unmatched `}` found | ^^^^^^^^^^^^^^ | = note: if you intended to print `}`, you can escape it using `}}` - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/lifetimes/borrowck-let-suggestion.stderr b/src/test/ui/lifetimes/borrowck-let-suggestion.stderr index bd717b1b6e513..70cde44e4c7e3 100644 --- a/src/test/ui/lifetimes/borrowck-let-suggestion.stderr +++ b/src/test/ui/lifetimes/borrowck-let-suggestion.stderr @@ -9,7 +9,7 @@ error[E0597]: borrowed value does not live long enough | - temporary value needs to live until here | = note: consider using a `let` binding to increase its lifetime - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/macro_backtrace/main.rs b/src/test/ui/macro_backtrace/main.rs index 4da0c586d6008..443574073f881 100644 --- a/src/test/ui/macro_backtrace/main.rs +++ b/src/test/ui/macro_backtrace/main.rs @@ -10,7 +10,7 @@ // Test that the macro backtrace facility works // aux-build:ping.rs -// rustc-env:RUST_MACRO_BACKTRACE +// compile-flags: -Z macro-backtrace #[macro_use] extern crate ping; diff --git a/src/test/ui/macros/format-foreign.stderr b/src/test/ui/macros/format-foreign.stderr index f6412cae44ac7..4d82aa437fb3e 100644 --- a/src/test/ui/macros/format-foreign.stderr +++ b/src/test/ui/macros/format-foreign.stderr @@ -11,7 +11,7 @@ error: multiple unused formatting arguments = help: `%.*3$s` should be written as `{:.2$}` = help: `%s` should be written as `{}` = note: printf formatting not supported; see the documentation for `std::fmt` - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: argument never used --> $DIR/format-foreign.rs:13:29 diff --git a/src/test/ui/macros/format-unused-lables.stderr b/src/test/ui/macros/format-unused-lables.stderr index 33d9889d127f5..1169ec11d2af8 100644 --- a/src/test/ui/macros/format-unused-lables.stderr +++ b/src/test/ui/macros/format-unused-lables.stderr @@ -8,7 +8,7 @@ error: multiple unused formatting arguments | | unused | unused | - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: multiple unused formatting arguments --> $DIR/format-unused-lables.rs:14:5 @@ -23,7 +23,7 @@ error: multiple unused formatting arguments 18 | | ); | |______^ | - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: named argument never used --> $DIR/format-unused-lables.rs:20:35 @@ -47,7 +47,7 @@ error: multiple unused formatting arguments | = help: `$STUFF` should be written as `{STUFF}` = note: shell formatting not supported; see the documentation for `std::fmt` - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: aborting due to 4 previous errors diff --git a/src/test/ui/reachable/expr_again.stderr b/src/test/ui/reachable/expr_again.stderr index fdc309ed99961..ec659af008e60 100644 --- a/src/test/ui/reachable/expr_again.stderr +++ b/src/test/ui/reachable/expr_again.stderr @@ -9,7 +9,7 @@ note: lint level defined here | 13 | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/reachable/expr_block.stderr b/src/test/ui/reachable/expr_block.stderr index 1c03c26609c6a..074d43d3b3983 100644 --- a/src/test/ui/reachable/expr_block.stderr +++ b/src/test/ui/reachable/expr_block.stderr @@ -16,7 +16,7 @@ error: unreachable statement 36 | println!("foo"); | ^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/reachable/expr_if.stderr b/src/test/ui/reachable/expr_if.stderr index bb5acd4b14332..c3841a851000d 100644 --- a/src/test/ui/reachable/expr_if.stderr +++ b/src/test/ui/reachable/expr_if.stderr @@ -9,7 +9,7 @@ note: lint level defined here | 14 | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/reachable/expr_loop.stderr b/src/test/ui/reachable/expr_loop.stderr index e1f1f9a5fb4db..d9066a9ad939f 100644 --- a/src/test/ui/reachable/expr_loop.stderr +++ b/src/test/ui/reachable/expr_loop.stderr @@ -9,7 +9,7 @@ note: lint level defined here | 14 | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: unreachable statement --> $DIR/expr_loop.rs:31:5 @@ -17,7 +17,7 @@ error: unreachable statement 31 | println!("I am dead."); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: unreachable statement --> $DIR/expr_loop.rs:41:5 @@ -25,7 +25,7 @@ error: unreachable statement 41 | println!("I am dead."); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/reachable/expr_match.stderr b/src/test/ui/reachable/expr_match.stderr index 585d036731185..0580016070ce1 100644 --- a/src/test/ui/reachable/expr_match.stderr +++ b/src/test/ui/reachable/expr_match.stderr @@ -16,7 +16,7 @@ error: unreachable statement 25 | println!("I am dead"); | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: unreachable statement --> $DIR/expr_match.rs:35:5 @@ -24,7 +24,7 @@ error: unreachable statement 35 | println!("I am dead"); | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/reachable/expr_while.stderr b/src/test/ui/reachable/expr_while.stderr index 87d1ac97712a7..98c6cb66d5947 100644 --- a/src/test/ui/reachable/expr_while.stderr +++ b/src/test/ui/reachable/expr_while.stderr @@ -9,7 +9,7 @@ note: lint level defined here | 14 | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: unreachable statement --> $DIR/expr_while.rs:33:9 @@ -17,7 +17,7 @@ error: unreachable statement 33 | println!("I am dead."); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: unreachable statement --> $DIR/expr_while.rs:35:5 @@ -25,7 +25,7 @@ error: unreachable statement 35 | println!("I am, too."); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/span/coerce-suggestions.stderr b/src/test/ui/span/coerce-suggestions.stderr index 9a43a869b6020..426f7b7462445 100644 --- a/src/test/ui/span/coerce-suggestions.stderr +++ b/src/test/ui/span/coerce-suggestions.stderr @@ -56,7 +56,7 @@ error[E0308]: mismatched types = note: expected type `&mut std::string::String` found type `std::string::String` = help: try with `&mut format!("foo")` - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: aborting due to 6 previous errors diff --git a/src/test/ui/span/issue-33884.stderr b/src/test/ui/span/issue-33884.stderr index 38515268c733d..bee9b20099f0f 100644 --- a/src/test/ui/span/issue-33884.stderr +++ b/src/test/ui/span/issue-33884.stderr @@ -6,7 +6,7 @@ error[E0308]: mismatched types | = note: expected type `std::fmt::Arguments<'_>` found type `std::string::String` - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/span/issue-40157.stderr b/src/test/ui/span/issue-40157.stderr index 4826410de30e5..c7f8ebab4763d 100644 --- a/src/test/ui/span/issue-40157.stderr +++ b/src/test/ui/span/issue-40157.stderr @@ -8,7 +8,7 @@ error[E0597]: `foo` does not live long enough | | borrow occurs here | borrowed value needs to live until here | - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/span/slice-borrow.stderr b/src/test/ui/span/slice-borrow.stderr index 679cba9f59c4e..dcfeb9fa16e9c 100644 --- a/src/test/ui/span/slice-borrow.stderr +++ b/src/test/ui/span/slice-borrow.stderr @@ -9,7 +9,7 @@ error[E0597]: borrowed value does not live long enough 19 | } | - temporary value needs to live until here | - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/type-check/cannot_infer_local_or_vec.stderr b/src/test/ui/type-check/cannot_infer_local_or_vec.stderr index 06550634cc818..5e11af14f1b04 100644 --- a/src/test/ui/type-check/cannot_infer_local_or_vec.stderr +++ b/src/test/ui/type-check/cannot_infer_local_or_vec.stderr @@ -6,7 +6,7 @@ error[E0282]: type annotations needed | | | consider giving `x` a type | - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/type-check/cannot_infer_local_or_vec_in_tuples.stderr b/src/test/ui/type-check/cannot_infer_local_or_vec_in_tuples.stderr index 8ec68b6133aa5..a6936e9ea1fe7 100644 --- a/src/test/ui/type-check/cannot_infer_local_or_vec_in_tuples.stderr +++ b/src/test/ui/type-check/cannot_infer_local_or_vec_in_tuples.stderr @@ -6,7 +6,7 @@ error[E0282]: type annotations needed | | | consider giving the pattern a type | - = note: this error originates in a macro outside of the current crate (run with RUST_MACRO_BACKTRACE=1 for more info) + = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) error: aborting due to previous error From 28f9ffbca14c597e9fad8d2ea9efd113c17afe6d Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Mon, 20 Nov 2017 01:01:09 +0000 Subject: [PATCH 5/7] break rustfmt --- src/tools/toolstate.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/toolstate.toml b/src/tools/toolstate.toml index 744a0f96ad734..59b8e1856dc16 100644 --- a/src/tools/toolstate.toml +++ b/src/tools/toolstate.toml @@ -32,4 +32,4 @@ clippy = "Testing" rls = "Testing" # ping @nrc -rustfmt = "Testing" +rustfmt = "Broken" From 30a661409cbdd0fb7ab4386952d9e0ecdd78abfa Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Mon, 20 Nov 2017 01:23:44 +0000 Subject: [PATCH 6/7] =?UTF-8?q?tidy=20=F0=9F=98=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/librustc_driver/lib.rs | 3 ++- src/librustdoc/test.rs | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 2f847e3dd97eb..5ed549d0bbd2c 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -141,7 +141,8 @@ pub fn run(run_compiler: F) -> isize errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto, None, true); - let handler = errors::Handler::with_emitter(true, false, false, Box::new(emitter)); + let handler = errors::Handler::with_emitter(true, false, false, + Box::new(emitter)); handler.emit(&MultiSpan::new(), "aborting due to previous error(s)", errors::Level::Fatal); diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 03cb77422cf5c..cc59afb00d4b0 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -81,7 +81,9 @@ pub fn run(input: &str, let codemap = Rc::new(CodeMap::new(sessopts.file_path_mapping())); let handler = - errors::Handler::with_tty_emitter(ColorConfig::Auto, true, false, false, Some(codemap.clone())); + errors::Handler::with_tty_emitter(ColorConfig::Auto, + true, false, false, + Some(codemap.clone())); let cstore = Rc::new(CStore::new(box rustc_trans::LlvmMetadataLoader)); let mut sess = session::build_session_( From b34a7ffb2524bbe2e8d563a846f6c9f8e2453c1a Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Mon, 20 Nov 2017 18:03:20 +0000 Subject: [PATCH 7/7] address review comments --- src/librustc/session/config.rs | 10 +-- src/librustc/session/mod.rs | 20 +++--- src/librustc_driver/lib.rs | 5 +- src/librustc_driver/test.rs | 2 +- src/librustc_errors/emitter.rs | 16 ++--- src/librustc_errors/lib.rs | 62 +++++++++++++------ src/librustc_trans/back/write.rs | 2 +- src/librustdoc/core.rs | 1 - src/librustdoc/test.rs | 4 +- src/libsyntax/parse/lexer/mod.rs | 2 +- src/libsyntax/parse/mod.rs | 1 - src/libsyntax/parse/obsolete.rs | 2 +- src/libsyntax/test_snippet.rs | 2 +- .../ui/codemap_tests/bad-format-args.stderr | 6 +- src/test/ui/codemap_tests/issue-28308.stderr | 2 +- .../cross-crate-macro-backtrace/main.stderr | 2 +- src/test/ui/fmt/format-string-error.stderr | 4 +- .../lifetimes/borrowck-let-suggestion.stderr | 2 +- src/test/ui/macro_backtrace/main.rs | 2 +- src/test/ui/macros/format-foreign.stderr | 2 +- .../ui/macros/format-unused-lables.stderr | 6 +- src/test/ui/reachable/expr_again.stderr | 2 +- src/test/ui/reachable/expr_block.stderr | 2 +- src/test/ui/reachable/expr_if.stderr | 2 +- src/test/ui/reachable/expr_loop.stderr | 6 +- src/test/ui/reachable/expr_match.stderr | 4 +- src/test/ui/reachable/expr_while.stderr | 6 +- src/test/ui/span/coerce-suggestions.stderr | 2 +- src/test/ui/span/issue-33884.stderr | 2 +- src/test/ui/span/issue-40157.stderr | 2 +- src/test/ui/span/slice-borrow.stderr | 2 +- .../cannot_infer_local_or_vec.stderr | 2 +- ...cannot_infer_local_or_vec_in_tuples.stderr | 2 +- src/tools/toolstate.toml | 2 +- 34 files changed, 109 insertions(+), 82 deletions(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 25123acdc674f..ee197a009f8ad 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1036,8 +1036,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "run all passes except translation; no output"), treat_err_as_bug: bool = (false, parse_bool, [TRACKED], "treat all errors that occur as bugs"), - macro_backtrace: bool = (false, parse_bool, [UNTRACKED], - "show macro backtraces even for foreign macros"), + external_macro_backtrace: bool = (false, parse_bool, [UNTRACKED], + "show macro backtraces even for non-local macros"), continue_parse_after_error: bool = (false, parse_bool, [TRACKED], "attempt to recover from parse errors (experimental)"), incremental: Option = (None, parse_opt_string, [UNTRACKED], @@ -2102,7 +2102,7 @@ mod tests { let registry = errors::registry::Registry::new(&[]); let (sessopts, _) = build_session_options_and_crate_config(&matches); let sess = build_session(sessopts, None, registry); - assert!(!sess.diagnostic().can_emit_warnings); + assert!(!sess.diagnostic().flags.can_emit_warnings); } { @@ -2113,7 +2113,7 @@ mod tests { let registry = errors::registry::Registry::new(&[]); let (sessopts, _) = build_session_options_and_crate_config(&matches); let sess = build_session(sessopts, None, registry); - assert!(sess.diagnostic().can_emit_warnings); + assert!(sess.diagnostic().flags.can_emit_warnings); } { @@ -2123,7 +2123,7 @@ mod tests { let registry = errors::registry::Registry::new(&[]); let (sessopts, _) = build_session_options_and_crate_config(&matches); let sess = build_session(sessopts, None, registry); - assert!(sess.diagnostic().can_emit_warnings); + assert!(sess.diagnostic().flags.can_emit_warnings); } } diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index ab270648f3a2f..b2a27d927deca 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -727,11 +727,11 @@ pub fn build_session_with_codemap(sopts: config::Options, .unwrap_or(false); let cap_lints_allow = sopts.lint_cap.map_or(false, |cap| cap == lint::Allow); - let can_print_warnings = !(warnings_allow || cap_lints_allow); + let can_emit_warnings = !(warnings_allow || cap_lints_allow); let treat_err_as_bug = sopts.debugging_opts.treat_err_as_bug; - let macro_backtrace = sopts.debugging_opts.macro_backtrace; + let external_macro_backtrace = sopts.debugging_opts.external_macro_backtrace; let emitter: Box = match (sopts.error_format, emitter_dest) { (config::ErrorOutputType::HumanReadable(color_config), None) => { @@ -755,10 +755,14 @@ pub fn build_session_with_codemap(sopts: config::Options, }; let diagnostic_handler = - errors::Handler::with_emitter(can_print_warnings, - treat_err_as_bug, - macro_backtrace, - emitter); + errors::Handler::with_emitter_and_flags( + emitter, + errors::HandlerFlags { + can_emit_warnings, + treat_err_as_bug, + external_macro_backtrace, + .. Default::default() + }); build_session_(sopts, local_crate_source_file, @@ -928,7 +932,7 @@ pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! { Box::new(EmitterWriter::stderr(color_config, None, true)) } }; - let handler = errors::Handler::with_emitter(true, false, false, emitter); + let handler = errors::Handler::with_emitter(true, false, emitter); handler.emit(&MultiSpan::new(), msg, errors::Level::Fatal); panic!(errors::FatalError); } @@ -943,7 +947,7 @@ pub fn early_warn(output: config::ErrorOutputType, msg: &str) { Box::new(EmitterWriter::stderr(color_config, None, true)) } }; - let handler = errors::Handler::with_emitter(true, false, false, emitter); + let handler = errors::Handler::with_emitter(true, false, emitter); handler.emit(&MultiSpan::new(), msg, errors::Level::Warning); } diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 5ed549d0bbd2c..c5cce70c94566 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -141,8 +141,7 @@ pub fn run(run_compiler: F) -> isize errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto, None, true); - let handler = errors::Handler::with_emitter(true, false, false, - Box::new(emitter)); + let handler = errors::Handler::with_emitter(true, false, Box::new(emitter)); handler.emit(&MultiSpan::new(), "aborting due to previous error(s)", errors::Level::Fatal); @@ -1222,7 +1221,7 @@ pub fn monitor(f: F) { Box::new(errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto, None, false)); - let handler = errors::Handler::with_emitter(true, false, false, emitter); + let handler = errors::Handler::with_emitter(true, false, emitter); // a .span_bug or .bug call has already printed what // it wants to print. diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 8a4cc2378052e..78ce959e5c94e 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -104,7 +104,7 @@ fn test_env(source_string: &str, let mut options = config::basic_options(); options.debugging_opts.verbose = true; options.unstable_features = UnstableFeatures::Allow; - let diagnostic_handler = errors::Handler::with_emitter(true, false, false, emitter); + let diagnostic_handler = errors::Handler::with_emitter(true, false, emitter); let cstore = Rc::new(CStore::new(::DefaultTransCrate::metadata_loader())); let sess = session::build_session_(options, diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index f3f5b443a4306..17ed1734fe203 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -64,11 +64,11 @@ impl Emitter for EmitterWriter { } } - if !db.handler.macro_backtrace { + if !db.handler.flags.external_macro_backtrace { self.fix_multispans_in_std_macros(&mut primary_span, &mut children); } self.emit_messages_default(&db.level, - db.handler.macro_backtrace, + db.handler.flags.external_macro_backtrace, &db.styled_message(), &db.code, &primary_span, @@ -798,7 +798,7 @@ impl EmitterWriter { level: Level::Note, message: vec![ (["this error originates in a macro outside of the current crate", - "(run with -Z macro-backtrace for more info)"].join(" "), + "(run with -Z external-macro-backtrace for more info)"].join(" "), Style::NoStyle), ], span: MultiSpan::new(), @@ -888,7 +888,7 @@ impl EmitterWriter { msg: &Vec<(String, Style)>, code: &Option, level: &Level, - macro_backtrace: bool, + external_macro_backtrace: bool, max_line_num_len: usize, is_secondary: bool) -> io::Result<()> { @@ -1086,7 +1086,7 @@ impl EmitterWriter { } } - if macro_backtrace { + if external_macro_backtrace { if let Some(ref primary_span) = msp.primary_span().as_ref() { self.render_macro_backtrace_old_school(primary_span, &mut buffer)?; } @@ -1183,7 +1183,7 @@ impl EmitterWriter { } fn emit_messages_default(&mut self, level: &Level, - macro_backtrace: bool, + external_macro_backtrace: bool, message: &Vec<(String, Style)>, code: &Option, span: &MultiSpan, @@ -1196,7 +1196,7 @@ impl EmitterWriter { message, code, level, - macro_backtrace, + external_macro_backtrace, max_line_num_len, false) { Ok(()) => { @@ -1218,7 +1218,7 @@ impl EmitterWriter { &child.styled_message(), &None, &child.level, - macro_backtrace, + external_macro_backtrace, max_line_num_len, true) { Err(e) => panic!("failed to emit error: {}", e), diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 99d94aaf912a0..605cfc5ed127e 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -233,11 +233,10 @@ pub use diagnostic_builder::DiagnosticBuilder; /// (fatal, bug, unimpl) may cause immediate exit, /// others log errors for later reporting. pub struct Handler { + pub flags: HandlerFlags, + err_count: Cell, emitter: RefCell>, - pub can_emit_warnings: bool, - treat_err_as_bug: bool, - pub macro_backtrace: bool, continue_after_error: Cell, delayed_span_bug: RefCell>, tracked_diagnostics: RefCell>>, @@ -248,28 +247,55 @@ pub struct Handler { emitted_diagnostics: RefCell>, } +#[derive(Default)] +pub struct HandlerFlags { + pub can_emit_warnings: bool, + pub treat_err_as_bug: bool, + pub external_macro_backtrace: bool, +} + impl Handler { pub fn with_tty_emitter(color_config: ColorConfig, can_emit_warnings: bool, treat_err_as_bug: bool, - macro_backtrace: bool, cm: Option>) -> Handler { + Handler::with_tty_emitter_and_flags( + color_config, + cm, + HandlerFlags { + can_emit_warnings, + treat_err_as_bug, + .. Default::default() + }) + } + + pub fn with_tty_emitter_and_flags(color_config: ColorConfig, + cm: Option>, + flags: HandlerFlags) + -> Handler { let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false)); - Handler::with_emitter(can_emit_warnings, treat_err_as_bug, macro_backtrace, emitter) + Handler::with_emitter_and_flags(emitter, flags) } pub fn with_emitter(can_emit_warnings: bool, treat_err_as_bug: bool, - macro_backtrace: bool, e: Box) -> Handler { + Handler::with_emitter_and_flags( + e, + HandlerFlags { + can_emit_warnings, + treat_err_as_bug, + .. Default::default() + }) + } + + pub fn with_emitter_and_flags(e: Box, flags: HandlerFlags) -> Handler { Handler { + flags, err_count: Cell::new(0), emitter: RefCell::new(e), - can_emit_warnings, - treat_err_as_bug, - macro_backtrace, continue_after_error: Cell::new(true), delayed_span_bug: RefCell::new(None), tracked_diagnostics: RefCell::new(None), @@ -297,7 +323,7 @@ impl Handler { -> DiagnosticBuilder<'a> { let mut result = DiagnosticBuilder::new(self, Level::Warning, msg); result.set_span(sp); - if !self.can_emit_warnings { + if !self.flags.can_emit_warnings { result.cancel(); } result @@ -310,14 +336,14 @@ impl Handler { let mut result = DiagnosticBuilder::new(self, Level::Warning, msg); result.set_span(sp); result.code(code); - if !self.can_emit_warnings { + if !self.flags.can_emit_warnings { result.cancel(); } result } pub fn struct_warn<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a> { let mut result = DiagnosticBuilder::new(self, Level::Warning, msg); - if !self.can_emit_warnings { + if !self.flags.can_emit_warnings { result.cancel(); } result @@ -380,7 +406,7 @@ impl Handler { } fn panic_if_treat_err_as_bug(&self) { - if self.treat_err_as_bug { + if self.flags.treat_err_as_bug { panic!("encountered error with `-Z treat_err_as_bug"); } } @@ -422,7 +448,7 @@ impl Handler { panic!(ExplicitBug); } pub fn delay_span_bug>(&self, sp: S, msg: &str) { - if self.treat_err_as_bug { + if self.flags.treat_err_as_bug { self.span_bug(sp, msg); } let mut diagnostic = Diagnostic::new(Level::Bug, msg); @@ -447,7 +473,7 @@ impl Handler { self.span_bug(sp, &format!("unimplemented {}", msg)); } pub fn fatal(&self, msg: &str) -> FatalError { - if self.treat_err_as_bug { + if self.flags.treat_err_as_bug { self.bug(msg); } let mut db = DiagnosticBuilder::new(self, Fatal, msg); @@ -455,7 +481,7 @@ impl Handler { FatalError } pub fn err(&self, msg: &str) { - if self.treat_err_as_bug { + if self.flags.treat_err_as_bug { self.bug(msg); } let mut db = DiagnosticBuilder::new(self, Error, msg); @@ -508,7 +534,7 @@ impl Handler { panic!(self.fatal(&s)); } pub fn emit(&self, msp: &MultiSpan, msg: &str, lvl: Level) { - if lvl == Warning && !self.can_emit_warnings { + if lvl == Warning && !self.flags.can_emit_warnings { return; } let mut db = DiagnosticBuilder::new(self, lvl, msg); @@ -519,7 +545,7 @@ impl Handler { } } pub fn emit_with_code(&self, msp: &MultiSpan, msg: &str, code: DiagnosticId, lvl: Level) { - if lvl == Warning && !self.can_emit_warnings { + if lvl == Warning && !self.flags.can_emit_warnings { return; } let mut db = DiagnosticBuilder::new_with_code(self, lvl, Some(code), msg); diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 180a2f4ed6c6d..e443f13a7a1ca 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -353,7 +353,7 @@ pub struct CodegenContext { impl CodegenContext { pub fn create_diag_handler(&self) -> Handler { - Handler::with_emitter(true, false, false, Box::new(self.diag_emitter.clone())) + Handler::with_emitter(true, false, Box::new(self.diag_emitter.clone())) } pub fn config(&self, kind: ModuleKind) -> &ModuleConfig { diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 8db6cb51ce4a1..9172bfcde3f9e 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -141,7 +141,6 @@ pub fn run_core(search_paths: SearchPaths, let diagnostic_handler = errors::Handler::with_tty_emitter(ColorConfig::Auto, true, false, - false, Some(codemap.clone())); let cstore = Rc::new(CStore::new(box rustc_trans::LlvmMetadataLoader)); diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index cc59afb00d4b0..ea0d32e2a2d56 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -82,7 +82,7 @@ pub fn run(input: &str, let codemap = Rc::new(CodeMap::new(sessopts.file_path_mapping())); let handler = errors::Handler::with_tty_emitter(ColorConfig::Auto, - true, false, false, + true, false, Some(codemap.clone())); let cstore = Rc::new(CStore::new(box rustc_trans::LlvmMetadataLoader)); @@ -246,7 +246,7 @@ fn run_test(test: &str, cratename: &str, filename: &str, cfgs: Vec, libs let _bomb = Bomb(data.clone(), old.unwrap_or(box io::stdout())); // Compile the code - let diagnostic_handler = errors::Handler::with_emitter(true, false, false, box emitter); + let diagnostic_handler = errors::Handler::with_emitter(true, false, box emitter); let cstore = Rc::new(CStore::new(box rustc_trans::LlvmMetadataLoader)); let mut sess = session::build_session_( diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 924183fd64e0e..951163d35fa0f 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1726,7 +1726,7 @@ mod tests { Some(cm.clone()), false); ParseSess { - span_diagnostic: errors::Handler::with_emitter(true, false, false, Box::new(emitter)), + span_diagnostic: errors::Handler::with_emitter(true, false, Box::new(emitter)), unstable_features: UnstableFeatures::from_environment(), config: CrateConfig::new(), included_mod_stack: RefCell::new(Vec::new()), diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 11e4abdb3501f..c679efd41ea46 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -58,7 +58,6 @@ impl ParseSess { let handler = Handler::with_tty_emitter(ColorConfig::Auto, true, false, - false, Some(cm.clone())); ParseSess::with_span_handler(handler, cm) } diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 078e86aa2941f..49a697edf4164 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -58,7 +58,7 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> { }; if !self.obsolete_set.contains(&kind) && - (error || self.sess.span_diagnostic.can_emit_warnings) { + (error || self.sess.span_diagnostic.flags.can_emit_warnings) { err.note(desc); self.obsolete_set.insert(kind); } diff --git a/src/libsyntax/test_snippet.rs b/src/libsyntax/test_snippet.rs index 10ad440ca8580..a29250ea5f19f 100644 --- a/src/libsyntax/test_snippet.rs +++ b/src/libsyntax/test_snippet.rs @@ -62,7 +62,7 @@ fn test_harness(file_text: &str, span_labels: Vec, expected_output: & let emitter = EmitterWriter::new(Box::new(Shared { data: output.clone() }), Some(code_map.clone()), false); - let handler = Handler::with_emitter(true, false, false, Box::new(emitter)); + let handler = Handler::with_emitter(true, false, Box::new(emitter)); handler.span_err(msp, "foo"); assert!(expected_output.chars().next() == Some('\n'), diff --git a/src/test/ui/codemap_tests/bad-format-args.stderr b/src/test/ui/codemap_tests/bad-format-args.stderr index ba7e88103f5c6..7faabc6b3a6c6 100644 --- a/src/test/ui/codemap_tests/bad-format-args.stderr +++ b/src/test/ui/codemap_tests/bad-format-args.stderr @@ -4,7 +4,7 @@ error: requires at least a format string argument 12 | format!(); | ^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: expected token: `,` --> $DIR/bad-format-args.rs:13:5 @@ -12,7 +12,7 @@ error: expected token: `,` 13 | format!("" 1); | ^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: expected token: `,` --> $DIR/bad-format-args.rs:14:5 @@ -20,7 +20,7 @@ error: expected token: `,` 14 | format!("", 1 1); | ^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/codemap_tests/issue-28308.stderr b/src/test/ui/codemap_tests/issue-28308.stderr index a065e06926b50..bb91bbbc9e320 100644 --- a/src/test/ui/codemap_tests/issue-28308.stderr +++ b/src/test/ui/codemap_tests/issue-28308.stderr @@ -4,7 +4,7 @@ error[E0600]: cannot apply unary operator `!` to type `&'static str` 12 | assert!("foo"); | ^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/cross-crate-macro-backtrace/main.stderr b/src/test/ui/cross-crate-macro-backtrace/main.stderr index a6e589160a53a..7d5055deb895a 100644 --- a/src/test/ui/cross-crate-macro-backtrace/main.stderr +++ b/src/test/ui/cross-crate-macro-backtrace/main.stderr @@ -4,7 +4,7 @@ error: 1 positional argument in format string, but no arguments were given 16 | myprintln!("{}"); //~ ERROR in this macro | ^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/fmt/format-string-error.stderr b/src/test/ui/fmt/format-string-error.stderr index 9d45c84c03c86..1da8833e0f838 100644 --- a/src/test/ui/fmt/format-string-error.stderr +++ b/src/test/ui/fmt/format-string-error.stderr @@ -5,7 +5,7 @@ error: invalid format string: expected `'}'` but string was terminated | ^^^^^^^^^^^^^^ | = note: if you intended to print `{`, you can escape it using `{{` - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: invalid format string: unmatched `}` found --> $DIR/format-string-error.rs:14:5 @@ -14,7 +14,7 @@ error: invalid format string: unmatched `}` found | ^^^^^^^^^^^^^^ | = note: if you intended to print `}`, you can escape it using `}}` - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/lifetimes/borrowck-let-suggestion.stderr b/src/test/ui/lifetimes/borrowck-let-suggestion.stderr index 70cde44e4c7e3..ea8aafadc8e79 100644 --- a/src/test/ui/lifetimes/borrowck-let-suggestion.stderr +++ b/src/test/ui/lifetimes/borrowck-let-suggestion.stderr @@ -9,7 +9,7 @@ error[E0597]: borrowed value does not live long enough | - temporary value needs to live until here | = note: consider using a `let` binding to increase its lifetime - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/macro_backtrace/main.rs b/src/test/ui/macro_backtrace/main.rs index 443574073f881..488aeddbf549b 100644 --- a/src/test/ui/macro_backtrace/main.rs +++ b/src/test/ui/macro_backtrace/main.rs @@ -10,7 +10,7 @@ // Test that the macro backtrace facility works // aux-build:ping.rs -// compile-flags: -Z macro-backtrace +// compile-flags: -Z external-macro-backtrace #[macro_use] extern crate ping; diff --git a/src/test/ui/macros/format-foreign.stderr b/src/test/ui/macros/format-foreign.stderr index 4d82aa437fb3e..cb27bb2281d26 100644 --- a/src/test/ui/macros/format-foreign.stderr +++ b/src/test/ui/macros/format-foreign.stderr @@ -11,7 +11,7 @@ error: multiple unused formatting arguments = help: `%.*3$s` should be written as `{:.2$}` = help: `%s` should be written as `{}` = note: printf formatting not supported; see the documentation for `std::fmt` - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: argument never used --> $DIR/format-foreign.rs:13:29 diff --git a/src/test/ui/macros/format-unused-lables.stderr b/src/test/ui/macros/format-unused-lables.stderr index 1169ec11d2af8..0205e9a9bfca3 100644 --- a/src/test/ui/macros/format-unused-lables.stderr +++ b/src/test/ui/macros/format-unused-lables.stderr @@ -8,7 +8,7 @@ error: multiple unused formatting arguments | | unused | unused | - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: multiple unused formatting arguments --> $DIR/format-unused-lables.rs:14:5 @@ -23,7 +23,7 @@ error: multiple unused formatting arguments 18 | | ); | |______^ | - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: named argument never used --> $DIR/format-unused-lables.rs:20:35 @@ -47,7 +47,7 @@ error: multiple unused formatting arguments | = help: `$STUFF` should be written as `{STUFF}` = note: shell formatting not supported; see the documentation for `std::fmt` - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: aborting due to 4 previous errors diff --git a/src/test/ui/reachable/expr_again.stderr b/src/test/ui/reachable/expr_again.stderr index ec659af008e60..54b1d47710c97 100644 --- a/src/test/ui/reachable/expr_again.stderr +++ b/src/test/ui/reachable/expr_again.stderr @@ -9,7 +9,7 @@ note: lint level defined here | 13 | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/reachable/expr_block.stderr b/src/test/ui/reachable/expr_block.stderr index 074d43d3b3983..8a17d4e6278cc 100644 --- a/src/test/ui/reachable/expr_block.stderr +++ b/src/test/ui/reachable/expr_block.stderr @@ -16,7 +16,7 @@ error: unreachable statement 36 | println!("foo"); | ^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/reachable/expr_if.stderr b/src/test/ui/reachable/expr_if.stderr index c3841a851000d..2b77f5bb3ca54 100644 --- a/src/test/ui/reachable/expr_if.stderr +++ b/src/test/ui/reachable/expr_if.stderr @@ -9,7 +9,7 @@ note: lint level defined here | 14 | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/reachable/expr_loop.stderr b/src/test/ui/reachable/expr_loop.stderr index d9066a9ad939f..bcfe2c5bd634b 100644 --- a/src/test/ui/reachable/expr_loop.stderr +++ b/src/test/ui/reachable/expr_loop.stderr @@ -9,7 +9,7 @@ note: lint level defined here | 14 | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: unreachable statement --> $DIR/expr_loop.rs:31:5 @@ -17,7 +17,7 @@ error: unreachable statement 31 | println!("I am dead."); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: unreachable statement --> $DIR/expr_loop.rs:41:5 @@ -25,7 +25,7 @@ error: unreachable statement 41 | println!("I am dead."); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/reachable/expr_match.stderr b/src/test/ui/reachable/expr_match.stderr index 0580016070ce1..dcfefe109c383 100644 --- a/src/test/ui/reachable/expr_match.stderr +++ b/src/test/ui/reachable/expr_match.stderr @@ -16,7 +16,7 @@ error: unreachable statement 25 | println!("I am dead"); | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: unreachable statement --> $DIR/expr_match.rs:35:5 @@ -24,7 +24,7 @@ error: unreachable statement 35 | println!("I am dead"); | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/reachable/expr_while.stderr b/src/test/ui/reachable/expr_while.stderr index 98c6cb66d5947..31e63c324d2b1 100644 --- a/src/test/ui/reachable/expr_while.stderr +++ b/src/test/ui/reachable/expr_while.stderr @@ -9,7 +9,7 @@ note: lint level defined here | 14 | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: unreachable statement --> $DIR/expr_while.rs:33:9 @@ -17,7 +17,7 @@ error: unreachable statement 33 | println!("I am dead."); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: unreachable statement --> $DIR/expr_while.rs:35:5 @@ -25,7 +25,7 @@ error: unreachable statement 35 | println!("I am, too."); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/span/coerce-suggestions.stderr b/src/test/ui/span/coerce-suggestions.stderr index 426f7b7462445..07f49d999a4f4 100644 --- a/src/test/ui/span/coerce-suggestions.stderr +++ b/src/test/ui/span/coerce-suggestions.stderr @@ -56,7 +56,7 @@ error[E0308]: mismatched types = note: expected type `&mut std::string::String` found type `std::string::String` = help: try with `&mut format!("foo")` - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: aborting due to 6 previous errors diff --git a/src/test/ui/span/issue-33884.stderr b/src/test/ui/span/issue-33884.stderr index bee9b20099f0f..22eecb9d882f6 100644 --- a/src/test/ui/span/issue-33884.stderr +++ b/src/test/ui/span/issue-33884.stderr @@ -6,7 +6,7 @@ error[E0308]: mismatched types | = note: expected type `std::fmt::Arguments<'_>` found type `std::string::String` - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/span/issue-40157.stderr b/src/test/ui/span/issue-40157.stderr index c7f8ebab4763d..0879cb5fac251 100644 --- a/src/test/ui/span/issue-40157.stderr +++ b/src/test/ui/span/issue-40157.stderr @@ -8,7 +8,7 @@ error[E0597]: `foo` does not live long enough | | borrow occurs here | borrowed value needs to live until here | - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/span/slice-borrow.stderr b/src/test/ui/span/slice-borrow.stderr index dcfeb9fa16e9c..f9dbddd226f09 100644 --- a/src/test/ui/span/slice-borrow.stderr +++ b/src/test/ui/span/slice-borrow.stderr @@ -9,7 +9,7 @@ error[E0597]: borrowed value does not live long enough 19 | } | - temporary value needs to live until here | - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/type-check/cannot_infer_local_or_vec.stderr b/src/test/ui/type-check/cannot_infer_local_or_vec.stderr index 5e11af14f1b04..923dcd01070b8 100644 --- a/src/test/ui/type-check/cannot_infer_local_or_vec.stderr +++ b/src/test/ui/type-check/cannot_infer_local_or_vec.stderr @@ -6,7 +6,7 @@ error[E0282]: type annotations needed | | | consider giving `x` a type | - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/type-check/cannot_infer_local_or_vec_in_tuples.stderr b/src/test/ui/type-check/cannot_infer_local_or_vec_in_tuples.stderr index a6936e9ea1fe7..24f2cef4a6c69 100644 --- a/src/test/ui/type-check/cannot_infer_local_or_vec_in_tuples.stderr +++ b/src/test/ui/type-check/cannot_infer_local_or_vec_in_tuples.stderr @@ -6,7 +6,7 @@ error[E0282]: type annotations needed | | | consider giving the pattern a type | - = note: this error originates in a macro outside of the current crate (run with -Z macro-backtrace for more info) + = note: this error originates in a macro outside of the current crate (run with -Z external-macro-backtrace for more info) error: aborting due to previous error diff --git a/src/tools/toolstate.toml b/src/tools/toolstate.toml index 59b8e1856dc16..744a0f96ad734 100644 --- a/src/tools/toolstate.toml +++ b/src/tools/toolstate.toml @@ -32,4 +32,4 @@ clippy = "Testing" rls = "Testing" # ping @nrc -rustfmt = "Broken" +rustfmt = "Testing"