Skip to content

Commit fc32dee

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

File tree

104 files changed

+11
-264
lines changed

Some content is hidden

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

104 files changed

+11
-264
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/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/pass/alloc-access-tracking.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ note: read access at ALLOC[0..1]
1515
|
1616
LL | assert_eq!(*ptr, 42);
1717
| ^^^^^^^^^^^^^^^^^^^^ tracking was triggered here
18-
|
19-
= note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
2018

2119
note: freed allocation ALLOC
2220
--> RUSTLIB/alloc/src/boxed.rs:LL:CC

tests/ui/asm/aarch64/type-check-2.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ LL | asm!("{}", in(reg) vec![0]);
2121
| ^^^^^^^
2222
|
2323
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
24-
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
2524

2625
error: cannot use value of type `(i32, i32, i32)` for inline assembly
2726
--> $DIR/type-check-2.rs:36:28

tests/ui/asm/parse-error.stderr

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,16 +193,12 @@ error: asm template must be a string literal
193193
|
194194
LL | asm!(format!("{{{}}}", 0), in(reg) foo);
195195
| ^^^^^^^^^^^^^^^^^^^^
196-
|
197-
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
198196

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

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

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

371363
error: the `in` operand cannot be used with `global_asm!`
372364
--> $DIR/parse-error.rs:146:19

tests/ui/associated-consts/defaults-not-assumed-fail.stderr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ note: erroneous constant encountered
2323
|
2424
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26-
|
27-
= note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
2826

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

3835
error: aborting due to 1 previous error
3936

tests/ui/async-await/unreachable-lint-2.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ note: the lint level is defined here
1111
|
1212
LL | #![deny(unreachable_code)]
1313
| ^^^^^^^^^^^^^^^^
14-
= note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
1514

1615
error: aborting due to 1 previous error
1716

tests/ui/binop/binary-operation-error-on-function-70724.stderr

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ LL | assert_eq!(a, 0);
66
| |
77
| fn() -> i32 {a}
88
| {integer}
9-
|
10-
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
119

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

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

3430
error: aborting due to 3 previous errors
3531

tests/ui/binop/eq-vec.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ note: an implementation of `PartialEq` might be missing for `Foo`
1212
|
1313
LL | enum Foo {
1414
| ^^^^^^^^ must implement `PartialEq`
15-
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
1615
help: consider annotating `Foo` with `#[derive(PartialEq)]`
1716
|
1817
LL + #[derive(PartialEq)]

tests/ui/binop/function-comparison-errors-59488.stderr

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,18 @@ LL | assert_eq!(Foo::Bar, i);
8080
| |
8181
| fn(usize) -> Foo {Foo::Bar}
8282
| fn(usize) -> Foo {Foo::Bar}
83-
|
84-
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
8583

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

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

10296
error: aborting due to 10 previous errors
10397

0 commit comments

Comments
 (0)