Skip to content

Commit 4a27be6

Browse files
committed
Do not mention -Zmacro-backtrace for std macros that are a wrapper around a compiler intrinsic
1 parent 38c7129 commit 4a27be6

File tree

125 files changed

+13
-314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+13
-314
lines changed

compiler/rustc_expand/src/base.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,9 @@ pub struct SyntaxExtension {
849849
/// Should debuginfo for the macro be collapsed to the outermost expansion site (in other
850850
/// words, was the macro definition annotated with `#[collapse_debuginfo]`)?
851851
pub collapse_debuginfo: bool,
852+
/// Suppresses the "this error originates in the macro" note when a diagnostic points at this
853+
/// macro.
854+
pub hide_backtrace: bool,
852855
}
853856

854857
impl SyntaxExtension {
@@ -882,6 +885,7 @@ impl SyntaxExtension {
882885
allow_internal_unsafe: false,
883886
local_inner_macros: false,
884887
collapse_debuginfo: false,
888+
hide_backtrace: false,
885889
}
886890
}
887891

@@ -912,6 +916,12 @@ impl SyntaxExtension {
912916
collapse_table[flag as usize][attr as usize]
913917
}
914918

919+
fn get_hide_backtrace(attrs: &[hir::Attribute]) -> bool {
920+
// FIXME(estebank): instead of reusing `#[rustc_diagnostic_item]` as a proxy, introduce a
921+
// new attribute purely for this under the `#[diagnostic]` namespace.
922+
ast::attr::find_by_name(attrs, sym::rustc_diagnostic_item).is_some()
923+
}
924+
915925
/// Constructs a syntax extension with the given properties
916926
/// and other properties converted from attributes.
917927
pub fn new(
@@ -948,6 +958,7 @@ impl SyntaxExtension {
948958
// Not a built-in macro
949959
None => (None, helper_attrs),
950960
};
961+
let hide_backtrace = builtin_name.is_some() || Self::get_hide_backtrace(attrs);
951962

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

@@ -982,6 +993,7 @@ impl SyntaxExtension {
982993
allow_internal_unsafe,
983994
local_inner_macros,
984995
collapse_debuginfo,
996+
hide_backtrace,
985997
}
986998
}
987999

@@ -1061,7 +1073,7 @@ impl SyntaxExtension {
10611073
self.allow_internal_unsafe,
10621074
self.local_inner_macros,
10631075
self.collapse_debuginfo,
1064-
self.builtin_name.is_some(),
1076+
self.hide_backtrace,
10651077
)
10661078
}
10671079
}

src/tools/clippy/tests/ui/recursive_format_impl.stderr

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,72 +12,54 @@ error: using `self` as `Display` in `impl Display` will cause infinite recursion
1212
|
1313
LL | write!(f, "{}", self)
1414
| ^^^^^^^^^^^^^^^^^^^^^
15-
|
16-
= note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info)
1715

1816
error: using `self` as `Display` in `impl Display` will cause infinite recursion
1917
--> tests/ui/recursive_format_impl.rs:86:9
2018
|
2119
LL | write!(f, "{}", &self)
2220
| ^^^^^^^^^^^^^^^^^^^^^^
23-
|
24-
= note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info)
2521

2622
error: using `self` as `Debug` in `impl Debug` will cause infinite recursion
2723
--> tests/ui/recursive_format_impl.rs:93:9
2824
|
2925
LL | write!(f, "{:?}", &self)
3026
| ^^^^^^^^^^^^^^^^^^^^^^^^
31-
|
32-
= note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info)
3327

3428
error: using `self` as `Display` in `impl Display` will cause infinite recursion
3529
--> tests/ui/recursive_format_impl.rs:103:9
3630
|
3731
LL | write!(f, "{}", &&&self)
3832
| ^^^^^^^^^^^^^^^^^^^^^^^^
39-
|
40-
= note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info)
4133

4234
error: using `self` as `Display` in `impl Display` will cause infinite recursion
4335
--> tests/ui/recursive_format_impl.rs:178:9
4436
|
4537
LL | write!(f, "{}", &*self)
4638
| ^^^^^^^^^^^^^^^^^^^^^^^
47-
|
48-
= note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info)
4939

5040
error: using `self` as `Debug` in `impl Debug` will cause infinite recursion
5141
--> tests/ui/recursive_format_impl.rs:185:9
5242
|
5343
LL | write!(f, "{:?}", &*self)
5444
| ^^^^^^^^^^^^^^^^^^^^^^^^^
55-
|
56-
= note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info)
5745

5846
error: using `self` as `Display` in `impl Display` will cause infinite recursion
5947
--> tests/ui/recursive_format_impl.rs:202:9
6048
|
6149
LL | write!(f, "{}", *self)
6250
| ^^^^^^^^^^^^^^^^^^^^^^
63-
|
64-
= note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info)
6551

6652
error: using `self` as `Display` in `impl Display` will cause infinite recursion
6753
--> tests/ui/recursive_format_impl.rs:219:9
6854
|
6955
LL | write!(f, "{}", **&&*self)
7056
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
71-
|
72-
= note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info)
7357

7458
error: using `self` as `Display` in `impl Display` will cause infinite recursion
7559
--> tests/ui/recursive_format_impl.rs:236:9
7660
|
7761
LL | write!(f, "{}", &&**&&*self)
7862
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
79-
|
80-
= note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info)
8163

8264
error: aborting due to 10 previous errors
8365

src/tools/miri/tests/fail-dep/concurrency/windows_join_main.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ LL | | assert_eq!(WaitForSingleObject(MAIN_THREAD, INFINITE), WAIT_O
3131
LL | | }
3232
LL | | })
3333
| |______^
34-
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
3534

3635
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
3736

src/tools/miri/tests/fail/dangling_pointers/dangling_primitive.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ help: ALLOC was deallocated here:
1616
|
1717
LL | };
1818
| ^
19-
= note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
2019

2120
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
2221

src/tools/miri/tests/fail/dangling_pointers/out_of_bounds_read.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ help: ALLOC was allocated here:
1111
|
1212
LL | let v: Vec<u16> = vec![1, 2];
1313
| ^^^^^^^^^^
14-
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
1514

1615
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1716

src/tools/miri/tests/fail/dangling_pointers/out_of_bounds_read_neg_offset.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ help: ALLOC was allocated here:
1111
|
1212
LL | let v: Vec<u16> = vec![1, 2];
1313
| ^^^^^^^^^^
14-
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
1514

1615
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1716

src/tools/miri/tests/fail/dangling_pointers/out_of_bounds_write.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ help: ALLOC was allocated here:
1111
|
1212
LL | let mut v: Vec<u16> = vec![1, 2];
1313
| ^^^^^^^^^^
14-
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
1514

1615
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1716

src/tools/miri/tests/fail/erroneous_const2.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ note: erroneous constant encountered
2323
|
2424
LL | println!("{}", FOO);
2525
| ^^^
26-
|
27-
= 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)
2826

2927
error: aborting due to 1 previous error
3028

src/tools/miri/tests/fail/function_calls/return_pointer_on_unwind.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ LL | dbg!(x.0);
1111
|
1212
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
1313
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
14-
= note: this error originates in the macro `$crate::macros::dbg_internal` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
1514

1615
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
1716
ALLOC (stack variable, size: 132, align: 4) {

src/tools/miri/tests/fail/intrinsics/simd-scatter.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ help: ALLOC was allocated here:
1616
|
1717
LL | let mut vec: Vec<i8> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19-
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
2019

2120
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
2221

0 commit comments

Comments
 (0)