Skip to content

Commit ef13f17

Browse files
committed
Do not mention -Zmacro-backtrace for std macros that are a wrapper around a compiler intrinsic
1 parent 6e41e61 commit ef13f17

File tree

117 files changed

+11
-294
lines changed

Some content is hidden

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

117 files changed

+11
-294
lines changed

compiler/rustc_expand/src/base.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ pub struct SyntaxExtension {
851851
/// Should debuginfo for the macro be collapsed to the outermost expansion site (in other
852852
/// words, was the macro definition annotated with `#[collapse_debuginfo]`)?
853853
pub collapse_debuginfo: bool,
854+
pub hide_backtrace: bool,
854855
}
855856

856857
impl SyntaxExtension {
@@ -884,6 +885,7 @@ impl SyntaxExtension {
884885
allow_internal_unsafe: false,
885886
local_inner_macros: false,
886887
collapse_debuginfo: false,
888+
hide_backtrace: false,
887889
}
888890
}
889891

@@ -939,6 +941,12 @@ impl SyntaxExtension {
939941
collapse_table[flag as usize][attr as usize]
940942
}
941943

944+
fn get_hide_backtrace(attrs: &[hir::Attribute]) -> bool {
945+
// FIXME(estebank): instead of reusing `#[rustc_diagnostic_item]` as a proxy, introduce a
946+
// new attribute purely for this under the `#[diagnostic]` namespace.
947+
ast::attr::find_by_name(attrs, sym::rustc_diagnostic_item).is_some()
948+
}
949+
942950
/// Constructs a syntax extension with the given properties
943951
/// and other properties converted from attributes.
944952
pub fn new(
@@ -975,6 +983,7 @@ impl SyntaxExtension {
975983
// Not a built-in macro
976984
None => (None, helper_attrs),
977985
};
986+
let hide_backtrace = builtin_name.is_some() || Self::get_hide_backtrace(attrs);
978987

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

@@ -1009,6 +1018,7 @@ impl SyntaxExtension {
10091018
allow_internal_unsafe,
10101019
local_inner_macros,
10111020
collapse_debuginfo,
1021+
hide_backtrace,
10121022
}
10131023
}
10141024

@@ -1088,7 +1098,7 @@ impl SyntaxExtension {
10881098
self.allow_internal_unsafe,
10891099
self.local_inner_macros,
10901100
self.collapse_debuginfo,
1091-
self.builtin_name.is_some(),
1101+
self.hide_backtrace,
10921102
)
10931103
}
10941104
}

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/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 `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 `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

src/tools/miri/tests/fail/provenance/mix-ptrs1.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ LL | assert_eq!(*strange_ptr.with_addr(ptr.addr()), 0);
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9-
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
109

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

0 commit comments

Comments
 (0)