I tried this code:
// foo/src/lib.rs
#![feature(macro_attr)]
#[macro_export]
macro_rules! identity {
attr() (
$( $item:tt )*
) => {
$( $item )*
}
}
// bar/src/lib.rs
#[foo::identity]
pub fn problem() {}
I expected to see this happen: Error pointing to bar/src/lib.rs:2
Instead, this happened:
error[E0658]: `macro_rules!` attributes are unstable
--> /Users/kpreid/Desktop/attr/foo/src/lib.rs:4:1
|
4 | macro_rules! identity {
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_attr)]` to the crate attributes to enable
= note: this compiler was built on 2025-09-27; consider upgrading it if it is out of date
For more information about this error, try `rustc --explain E0658`.
error: could not compile `bar` (lib) due to 1 previous error
Therefore, it is impossible to tell which crate needs the attribute added except by examining Cargo's “could not compile” line.
Meta
rustc --version --verbose:
rustc 1.92.0-nightly (4082d6a3f 2025-09-27)
binary: rustc
commit-hash: 4082d6a3f0347c2fc4b8c8d5a6a38ed7248fa161
commit-date: 2025-09-27
host: aarch64-apple-darwin
release: 1.92.0-nightly
LLVM version: 21.1.2
@rustbot label A-macros A-diagnostics A-stability T-compiler
I tried this code:
I expected to see this happen: Error pointing to
bar/src/lib.rs:2Instead, this happened:
Therefore, it is impossible to tell which crate needs the attribute added except by examining Cargo's “could not compile” line.
Meta
rustc --version --verbose:@rustbot label A-macros A-diagnostics A-stability T-compiler