mbe: In error messages, don't assume attributes are always proc macros

Now that `macro_rules` macros can define attribute rules, make sure
error messages account for that.
This commit is contained in:
Josh Triplett 2025-07-28 03:00:24 -07:00
parent a980cd4311
commit 2054a0c56b
12 changed files with 17 additions and 17 deletions

View file

@ -409,7 +409,7 @@ pub trait Emitter {
if !redundant_span || always_backtrace {
let msg: Cow<'static, _> = match trace.kind {
ExpnKind::Macro(MacroKind::Attr, _) => {
"this procedural macro expansion".into()
"this attribute macro expansion".into()
}
ExpnKind::Macro(MacroKind::Derive, _) => {
"this derive macro expansion".into()

View file

@ -11,7 +11,7 @@ note: inside `_::__rg_oom`
--> tests/fail/alloc/alloc_error_handler_custom.rs:LL:CC
|
LL | #[alloc_error_handler]
| ---------------------- in this procedural macro expansion
| ---------------------- in this attribute macro expansion
LL | fn alloc_error_handler(layout: Layout) -> ! {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: inside `alloc::alloc::handle_alloc_error::rt_error` at RUSTLIB/alloc/src/alloc.rs:LL:CC

View file

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/alloc-error-handler-bad-signature-1.rs:10:1
|
LL | #[alloc_error_handler]
| ---------------------- in this procedural macro expansion
| ---------------------- in this attribute macro expansion
LL | // fn oom(
LL | || info: &Layout,
LL | || ) -> ()
@ -23,7 +23,7 @@ error[E0308]: mismatched types
--> $DIR/alloc-error-handler-bad-signature-1.rs:10:1
|
LL | #[alloc_error_handler]
| ---------------------- in this procedural macro expansion
| ---------------------- in this attribute macro expansion
LL | // fn oom(
LL | || info: &Layout,
LL | || ) -> ()

View file

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/alloc-error-handler-bad-signature-2.rs:10:1
|
LL | #[alloc_error_handler]
| ---------------------- in this procedural macro expansion
| ---------------------- in this attribute macro expansion
LL | // fn oom(
LL | || info: Layout,
LL | || ) {
@ -31,7 +31,7 @@ error[E0308]: mismatched types
--> $DIR/alloc-error-handler-bad-signature-2.rs:10:1
|
LL | #[alloc_error_handler]
| ---------------------- in this procedural macro expansion
| ---------------------- in this attribute macro expansion
LL | // fn oom(
LL | || info: Layout,
LL | || ) {

View file

@ -2,7 +2,7 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/alloc-error-handler-bad-signature-3.rs:10:1
|
LL | #[alloc_error_handler]
| ---------------------- in this procedural macro expansion
| ---------------------- in this attribute macro expansion
LL | fn oom() -> ! {
| _-^^^^^^^^^^^^
LL | | loop {}

View file

@ -2,7 +2,7 @@ error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
--> $DIR/not-an-allocator.rs:2:11
|
LL | #[global_allocator]
| ------------------- in this procedural macro expansion
| ------------------- in this attribute macro expansion
LL | static A: usize = 0;
| ^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
|
@ -12,7 +12,7 @@ error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
--> $DIR/not-an-allocator.rs:2:11
|
LL | #[global_allocator]
| ------------------- in this procedural macro expansion
| ------------------- in this attribute macro expansion
LL | static A: usize = 0;
| ^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
|
@ -23,7 +23,7 @@ error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
--> $DIR/not-an-allocator.rs:2:11
|
LL | #[global_allocator]
| ------------------- in this procedural macro expansion
| ------------------- in this attribute macro expansion
LL | static A: usize = 0;
| ^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
|
@ -34,7 +34,7 @@ error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
--> $DIR/not-an-allocator.rs:2:11
|
LL | #[global_allocator]
| ------------------- in this procedural macro expansion
| ------------------- in this attribute macro expansion
LL | static A: usize = 0;
| ^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
|

View file

@ -4,7 +4,7 @@ error: cannot define multiple global allocators
LL | static A: System = System;
| -------------------------- previous global allocator defined here
LL | #[global_allocator]
| ------------------- in this procedural macro expansion
| ------------------- in this attribute macro expansion
LL | static B: System = System;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot define a new global allocator

View file

@ -2,7 +2,7 @@ error[E0277]: the trait bound `TestDescAndFn: Testable` is not satisfied
--> $DIR/mismatch.rs:9:1
|
LL | #[test]
| ------- in this procedural macro expansion
| ------- in this attribute macro expansion
LL | fn wrong_kind(){}
| ^^^^^^^^^^^^^^^^^ the trait `Testable` is not implemented for `TestDescAndFn`
|

View file

@ -10,7 +10,7 @@ LL | field: MissingType
::: $DIR/span-from-proc-macro.rs:8:1
|
LL | #[error_from_attribute]
| ----------------------- in this procedural macro expansion
| ----------------------- in this attribute macro expansion
error[E0412]: cannot find type `OtherMissingType` in this scope
--> $DIR/auxiliary/span-from-proc-macro.rs:42:21

View file

@ -2,7 +2,7 @@ error[E0277]: the trait bound `f32: Termination` is not satisfied
--> $DIR/termination-trait-test-wrong-type.rs:6:31
|
LL | #[test]
| ------- in this procedural macro expansion
| ------- in this attribute macro expansion
LL | fn can_parse_zero_as_f32() -> Result<f32, ParseFloatError> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Termination` is not implemented for `f32`
|

View file

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-12997-2.rs:8:1
|
LL | #[bench]
| -------- in this procedural macro expansion
| -------- in this attribute macro expansion
LL | fn bar(x: isize) { }
| ^^^^^^^^^^^^^^^^^^^^
| |

View file

@ -26,7 +26,7 @@ error[E0277]: the trait bound `i32: Termination` is not satisfied
--> $DIR/test-function-signature.rs:9:13
|
LL | #[test]
| ------- in this procedural macro expansion
| ------- in this attribute macro expansion
LL | fn bar() -> i32 {
| ^^^ the trait `Termination` is not implemented for `i32`
|