Skip to content
Open
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
12 changes: 11 additions & 1 deletion compiler/rustc_expand/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,7 @@ pub struct SyntaxExtension {
/// Should debuginfo for the macro be collapsed to the outermost expansion site (in other
/// words, was the macro definition annotated with `#[collapse_debuginfo]`)?
pub collapse_debuginfo: bool,
pub hide_backtrace: bool,
}

impl SyntaxExtension {
Expand Down Expand Up @@ -884,6 +885,7 @@ impl SyntaxExtension {
allow_internal_unsafe: false,
local_inner_macros: false,
collapse_debuginfo: false,
hide_backtrace: false,
}
}

Expand Down Expand Up @@ -939,6 +941,12 @@ impl SyntaxExtension {
collapse_table[flag as usize][attr as usize]
}

fn get_hide_backtrace(attrs: &[hir::Attribute]) -> bool {
// FIXME(estebank): instead of reusing `#[rustc_diagnostic_item]` as a proxy, introduce a
// new attribute purely for this under the `#[diagnostic]` namespace.
ast::attr::find_by_name(attrs, sym::rustc_diagnostic_item).is_some()
}

/// Constructs a syntax extension with the given properties
/// and other properties converted from attributes.
pub fn new(
Expand Down Expand Up @@ -975,6 +983,7 @@ impl SyntaxExtension {
// Not a built-in macro
None => (None, helper_attrs),
};
let hide_backtrace = builtin_name.is_some() || Self::get_hide_backtrace(attrs);

let stability = find_attr!(attrs, AttributeKind::Stability { stability, .. } => *stability);

Expand Down Expand Up @@ -1009,6 +1018,7 @@ impl SyntaxExtension {
allow_internal_unsafe,
local_inner_macros,
collapse_debuginfo,
hide_backtrace,
}
}

Expand Down Expand Up @@ -1088,7 +1098,7 @@ impl SyntaxExtension {
self.allow_internal_unsafe,
self.local_inner_macros,
self.collapse_debuginfo,
self.builtin_name.is_some(),
self.hide_backtrace,
)
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/tools/miri/tests/fail/erroneous_const2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ note: erroneous constant encountered
|
LL | println!("{}", FOO);
| ^^^
|
= note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 1 previous error

Expand Down
2 changes: 0 additions & 2 deletions src/tools/miri/tests/pass/alloc-access-tracking.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ note: read access at ALLOC[0..1]
|
LL | assert_eq!(*ptr, 42);
| ^^^^^^^^^^^^^^^^^^^^ tracking was triggered here
|
= note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

note: freed allocation ALLOC
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
Expand Down
1 change: 0 additions & 1 deletion tests/ui/asm/aarch64/type-check-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ LL | asm!("{}", in(reg) vec![0]);
| ^^^^^^^
|
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)

error: cannot use value of type `(i32, i32, i32)` for inline assembly
--> $DIR/type-check-2.rs:36:28
Expand Down
8 changes: 0 additions & 8 deletions tests/ui/asm/parse-error.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,12 @@ error: asm template must be a string literal
|
LL | asm!(format!("{{{}}}", 0), in(reg) foo);
| ^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)

error: asm template must be a string literal
--> $DIR/parse-error.rs:86:21
|
LL | asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar);
| ^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)

error: _ cannot be used for input operands
--> $DIR/parse-error.rs:88:28
Expand Down Expand Up @@ -357,16 +353,12 @@ error: asm template must be a string literal
|
LL | global_asm!(format!("{{{}}}", 0), const FOO);
| ^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)

error: asm template must be a string literal
--> $DIR/parse-error.rs:143:20
|
LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR);
| ^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)

error: the `in` operand cannot be used with `global_asm!`
--> $DIR/parse-error.rs:146:19
Expand Down
3 changes: 0 additions & 3 deletions tests/ui/associated-consts/defaults-not-assumed-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ note: erroneous constant encountered
|
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

note: erroneous constant encountered
--> $DIR/defaults-not-assumed-fail.rs:34:5
Expand All @@ -33,7 +31,6 @@ LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
= note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 1 previous error

Expand Down
1 change: 0 additions & 1 deletion tests/ui/async-await/unreachable-lint-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ note: the lint level is defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
= note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ LL | assert_eq!(a, 0);
| |
| fn() -> i32 {a}
| {integer}
|
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
--> $DIR/binary-operation-error-on-function-70724.rs:7:5
Expand All @@ -17,7 +15,6 @@ LL | assert_eq!(a, 0);
|
= note: expected fn item `fn() -> i32 {a}`
found type `{integer}`
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: `fn() -> i32 {a}` doesn't implement `Debug`
--> $DIR/binary-operation-error-on-function-70724.rs:7:5
Expand All @@ -29,7 +26,6 @@ LL | assert_eq!(a, 0);
| ^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for fn item `fn() -> i32 {a}`
|
= help: use parentheses to call this function: `a()`
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 3 previous errors

Expand Down
1 change: 0 additions & 1 deletion tests/ui/binop/eq-vec.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ note: an implementation of `PartialEq` might be missing for `Foo`
|
LL | enum Foo {
| ^^^^^^^^ must implement `PartialEq`
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider annotating `Foo` with `#[derive(PartialEq)]`
|
LL + #[derive(PartialEq)]
Expand Down
6 changes: 0 additions & 6 deletions tests/ui/binop/function-comparison-errors-59488.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,18 @@ LL | assert_eq!(Foo::Bar, i);
| |
| fn(usize) -> Foo {Foo::Bar}
| fn(usize) -> Foo {Foo::Bar}
|
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: `fn(usize) -> Foo {Foo::Bar}` doesn't implement `Debug`
--> $DIR/function-comparison-errors-59488.rs:31:5
|
LL | assert_eq!(Foo::Bar, i);
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for fn item `fn(usize) -> Foo {Foo::Bar}`
|
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: `fn(usize) -> Foo {Foo::Bar}` doesn't implement `Debug`
--> $DIR/function-comparison-errors-59488.rs:31:5
|
LL | assert_eq!(Foo::Bar, i);
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for fn item `fn(usize) -> Foo {Foo::Bar}`
|
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 10 previous errors

Expand Down
3 changes: 0 additions & 3 deletions tests/ui/binop/issue-77910-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ LL | assert_eq!(foo, y);
| |
| for<'a> fn(&'a i32) -> &'a i32 {foo}
| _
|
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: `for<'a> fn(&'a i32) -> &'a i32 {foo}` doesn't implement `Debug`
--> $DIR/issue-77910-1.rs:8:5
Expand All @@ -19,7 +17,6 @@ LL | assert_eq!(foo, y);
| ^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for fn item `for<'a> fn(&'a i32) -> &'a i32 {foo}`
|
= help: use parentheses to call this function: `foo(/* &i32 */)`
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0381]: used binding `xs` isn't initialized
--> $DIR/issue-77910-1.rs:3:5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ LL | test(&vec![])
| argument requires that borrow lasts for `'static`
LL | }
| - temporary value is freed at the end of this statement
|
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 1 previous error

Expand Down
2 changes: 0 additions & 2 deletions tests/ui/borrowck/borrowck-and-init.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ LL | println!("{}", false && { i = 5; true });
| ----- binding initialized here in some conditions
LL | println!("{}", i);
| ^ `i` used here but it is possibly-uninitialized
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 1 previous error

Expand Down
1 change: 0 additions & 1 deletion tests/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ LL | let x = defer(&vec!["Goodbye", "world!"]);
LL | x.x[0];
| ------ borrow later used here
|
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider using a `let` binding to create a longer lived value
|
LL ~ let binding = vec!["Goodbye", "world!"];
Expand Down
1 change: 0 additions & 1 deletion tests/ui/borrowck/borrowck-break-uninit-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ LL | let x: isize;
LL | println!("{}", x);
| ^ `x` used here but it isn't initialized
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider assigning a value
|
LL | let x: isize = 42;
Expand Down
1 change: 0 additions & 1 deletion tests/ui/borrowck/borrowck-break-uninit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ LL | let x: isize;
LL | println!("{}", x);
| ^ `x` used here but it isn't initialized
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider assigning a value
|
LL | let x: isize = 42;
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/borrowck/borrowck-or-init.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ LL | println!("{}", false || { i = 5; true });
| ----- binding initialized here in some conditions
LL | println!("{}", i);
| ^ `i` used here but it is possibly-uninitialized
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 1 previous error

Expand Down
2 changes: 0 additions & 2 deletions tests/ui/borrowck/borrowck-while-break.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ LL | while cond {
...
LL | println!("{}", v);
| ^ `v` used here but it is possibly-uninitialized
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 1 previous error

Expand Down
2 changes: 0 additions & 2 deletions tests/ui/borrowck/issue-24267-flow-exit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ LL | loop { x = break; }
LL | println!("{}", x);
| ^ `x` used here but it isn't initialized
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider assigning a value
|
LL | let x: i32 = 42;
Expand All @@ -22,7 +21,6 @@ LL | for _ in 0..10 { x = continue; }
LL | println!("{}", x);
| ^ `x` used here but it isn't initialized
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider assigning a value
|
LL | let x: i32 = 42;
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/borrowck/issue-47646.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ LL | println!("{:?}", heap);
...
LL | };
| - ... and the mutable borrow might be used here, when that temporary is dropped and runs the destructor for type `(Option<std::collections::binary_heap::PeekMut<'_, i32>>, ())`
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 1 previous error

Expand Down
1 change: 0 additions & 1 deletion tests/ui/borrowck/issue-64453.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ note: function `format` is not const
--> $SRC_DIR/alloc/src/fmt.rs:LL:COL
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0507]: cannot move out of static item `settings_dir`
--> $DIR/issue-64453.rs:13:37
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ note: `Mine::make_string_bar` takes ownership of the receiver `self`, which move
|
LL | fn make_string_bar(mut self) -> Mine {
| ^^^^
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 1 previous error

Expand Down
10 changes: 0 additions & 10 deletions tests/ui/borrowck/suggest-assign-rvalue.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ LL | let my_float: f32;
LL | println!("my_float: {}", my_float);
| ^^^^^^^^ `my_float` used here but it isn't initialized
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider assigning a value
|
LL | let my_float: f32 = 3.14159;
Expand All @@ -33,7 +32,6 @@ LL | let demo: Demo;
LL | println!("demo: {:?}", demo);
| ^^^^ `demo` used here but it isn't initialized
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider assigning a value
|
LL | let demo: Demo = Default::default();
Expand All @@ -47,7 +45,6 @@ LL | let demo_no: DemoNoDef;
LL | println!("demo_no: {:?}", demo_no);
| ^^^^^^^ `demo_no` used here but it isn't initialized
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider assigning a value
|
LL | let demo_no: DemoNoDef = /* value */;
Expand All @@ -61,7 +58,6 @@ LL | let arr: [i32; 5];
LL | println!("arr: {:?}", arr);
| ^^^ `arr` used here but it isn't initialized
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider assigning a value
|
LL | let arr: [i32; 5] = [42; 5];
Expand All @@ -75,7 +71,6 @@ LL | let foo: Vec<&str>;
LL | println!("foo: {:?}", foo);
| ^^^ `foo` used here but it isn't initialized
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider assigning a value
|
LL | let foo: Vec<&str> = vec![];
Expand All @@ -89,7 +84,6 @@ LL | let my_string: String;
LL | println!("my_string: {}", my_string);
| ^^^^^^^^^ `my_string` used here but it isn't initialized
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider assigning a value
|
LL | let my_string: String = Default::default();
Expand All @@ -103,7 +97,6 @@ LL | let my_int: &i32;
LL | println!("my_int: {}", *my_int);
| ^^^^^^^ `*my_int` used here but it isn't initialized
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider assigning a value
|
LL | let my_int: &i32 = &42;
Expand All @@ -117,7 +110,6 @@ LL | let hello: &str;
LL | println!("hello: {}", hello);
| ^^^^^ `hello` used here but it isn't initialized
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider assigning a value
|
LL | let hello: &str = "";
Expand All @@ -130,8 +122,6 @@ LL | let never: !;
| ----- binding declared here but left uninitialized
LL | println!("never: {}", never);
| ^^^^^ `never` used here but it isn't initialized
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 10 previous errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ LL | println!("{}", arr[3]);
...
LL | c();
| - mutable borrow later used here
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0502]: cannot borrow `arr` as immutable because it is also borrowed as mutable
--> $DIR/arrays.rs:71:24
Expand Down
Loading
Loading