Skip to content

Commit 4698b36

Browse files
committed
Show macro name in 'this error originates in macro' message
When there are multiple macros in use, it can be difficult to tell which one was responsible for producing an error.
1 parent f019d28 commit 4698b36

34 files changed

+90
-90
lines changed

tests/ui-internal/default_lint.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ note: the lint level is defined here
1515
LL | #![deny(clippy::internal)]
1616
| ^^^^^^^^^^^^^^^^
1717
= note: `#[deny(clippy::default_lint)]` implied by `#[deny(clippy::internal)]`
18-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
18+
= note: this error originates in the macro `$crate::declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info)
1919

2020
error: aborting due to previous error
2121

tests/ui-internal/if_chain_style.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ LL | | }
5656
LL | | }
5757
| |_____^
5858
|
59-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
59+
= note: this error originates in the macro `__if_chain` (in Nightly builds, run with -Z macro-backtrace for more info)
6060

6161
error: `let` expression should be above the `if_chain!`
6262
--> $DIR/if_chain_style.rs:40:9

tests/ui-internal/lint_without_lint_pass.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ note: the lint level is defined here
1515
LL | #![deny(clippy::internal)]
1616
| ^^^^^^^^^^^^^^^^
1717
= note: `#[deny(clippy::lint_without_lint_pass)]` implied by `#[deny(clippy::internal)]`
18-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
18+
= note: this error originates in the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info)
1919

2020
error: aborting due to previous error
2121

tests/ui/assertions_on_constants.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | assert!(true);
66
|
77
= note: `-D clippy::assertions-on-constants` implied by `-D warnings`
88
= help: remove it
9-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
9+
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
1010

1111
error: `assert!(false)` should probably be replaced
1212
--> $DIR/assertions_on_constants.rs:12:5
@@ -15,7 +15,7 @@ LL | assert!(false);
1515
| ^^^^^^^^^^^^^^^
1616
|
1717
= help: use `panic!()` or `unreachable!()`
18-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
18+
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
1919

2020
error: `assert!(true)` will be optimized out by the compiler
2121
--> $DIR/assertions_on_constants.rs:13:5
@@ -24,7 +24,7 @@ LL | assert!(true, "true message");
2424
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2525
|
2626
= help: remove it
27-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
27+
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
2828

2929
error: `assert!(false, "false message")` should probably be replaced
3030
--> $DIR/assertions_on_constants.rs:14:5
@@ -33,7 +33,7 @@ LL | assert!(false, "false message");
3333
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3434
|
3535
= help: use `panic!("false message")` or `unreachable!("false message")`
36-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
36+
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
3737

3838
error: `assert!(false, msg.to_uppercase())` should probably be replaced
3939
--> $DIR/assertions_on_constants.rs:17:5
@@ -42,7 +42,7 @@ LL | assert!(false, msg.to_uppercase());
4242
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4343
|
4444
= help: use `panic!(msg.to_uppercase())` or `unreachable!(msg.to_uppercase())`
45-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
45+
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
4646

4747
error: `assert!(true)` will be optimized out by the compiler
4848
--> $DIR/assertions_on_constants.rs:20:5
@@ -51,7 +51,7 @@ LL | assert!(B);
5151
| ^^^^^^^^^^^
5252
|
5353
= help: remove it
54-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
54+
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
5555

5656
error: `assert!(false)` should probably be replaced
5757
--> $DIR/assertions_on_constants.rs:23:5
@@ -60,7 +60,7 @@ LL | assert!(C);
6060
| ^^^^^^^^^^^
6161
|
6262
= help: use `panic!()` or `unreachable!()`
63-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
63+
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
6464

6565
error: `assert!(false, "C message")` should probably be replaced
6666
--> $DIR/assertions_on_constants.rs:24:5
@@ -69,7 +69,7 @@ LL | assert!(C, "C message");
6969
| ^^^^^^^^^^^^^^^^^^^^^^^^
7070
|
7171
= help: use `panic!("C message")` or `unreachable!("C message")`
72-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
72+
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
7373

7474
error: `debug_assert!(true)` will be optimized out by the compiler
7575
--> $DIR/assertions_on_constants.rs:26:5
@@ -78,7 +78,7 @@ LL | debug_assert!(true);
7878
| ^^^^^^^^^^^^^^^^^^^^
7979
|
8080
= help: remove it
81-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
81+
= note: this error originates in the macro `$crate::assert` (in Nightly builds, run with -Z macro-backtrace for more info)
8282

8383
error: aborting due to 9 previous errors
8484

tests/ui/checked_unwrap/simple_conditionals.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ LL | $a.unwrap(); // unnecessary
5555
LL | m!(x);
5656
| ------ in this macro invocation
5757
|
58-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
58+
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
5959

6060
error: you checked before that `unwrap()` cannot fail, instead of checking and unwrapping, it's better to use `if let` or `match`
6161
--> $DIR/simple_conditionals.rs:54:9

tests/ui/collapsible_match2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ LL | mac!(res_opt => Ok(val), val => Some(n), foo(n));
5555
| ^^^ ^^^^^^^ with this pattern
5656
| |
5757
| replace this binding
58-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
58+
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
5959

6060
error: unnecessary nested match
6161
--> $DIR/collapsible_match2.rs:51:20

tests/ui/crashes/ice-6255.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | extern crate std as core;
77
LL | define_other_core!();
88
| --------------------- in this macro invocation
99
|
10-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
10+
= note: this error originates in the macro `define_other_core` (in Nightly builds, run with -Z macro-backtrace for more info)
1111

1212
error: aborting due to previous error
1313

tests/ui/declare_interior_mutable_const/others.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ LL | const $name: $ty = $e;
3333
LL | declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable
3434
| ------------------------------------------ in this macro invocation
3535
|
36-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
36+
= note: this error originates in the macro `declare_const` (in Nightly builds, run with -Z macro-backtrace for more info)
3737

3838
error: aborting due to 4 previous errors
3939

tests/ui/declare_interior_mutable_const/traits.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ LL | const $name: $ty = $e;
1515
LL | declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC); //~ ERROR interior mutable
1616
| ----------------------------------------------------------- in this macro invocation
1717
|
18-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
18+
= note: this error originates in the macro `declare_const` (in Nightly builds, run with -Z macro-backtrace for more info)
1919

2020
error: a `const` item should never be interior mutable
2121
--> $DIR/traits.rs:43:5

tests/ui/deref_addrof.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ LL | *& $visitor
5757
LL | m!(self)
5858
| -------- in this macro invocation
5959
|
60-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
60+
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
6161

6262
error: immediately dereferencing a reference
6363
--> $DIR/deref_addrof.rs:51:9
@@ -68,7 +68,7 @@ LL | *& mut $visitor
6868
LL | m_mut!(self)
6969
| ------------ in this macro invocation
7070
|
71-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
71+
= note: this error originates in the macro `m_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
7272

7373
error: aborting due to 10 previous errors
7474

0 commit comments

Comments
 (0)