Unexpected follow-up errors after proc-macro attribute panic
Open
Nobody has claimed this yet.
A-testsuite
C-bug
F-custom_inner_attributes
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
// auxiliary/panic-inducing.rs
extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro_attribute]
pub fn panic_inducing(_: TokenStream, _: TokenStream) -> TokenStream {
panic!();
}
// attr-panic-macro.rs
#![feature(custom_inner_attributes)]
#![panic_inducing::panic_inducing]
#[macro_use]
extern crate panic_inducing;
fn main() {}
I expected to see this happen: the compilation fails only with custom attribute panicked.
Instead, this happened:
error: custom attribute panicked
--> <path>/attr-macro-panic.rs:6:1
|
LL | #![panic_inducing::panic_inducing]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: message: explicit panic
error: `#[panic_handler]` function required, but not found
error: unwinding panics are not supported without std
|
= help: using nightly cargo, use -Zbuild-std with panic="abort" to avoid unwinding
= note: since the core library is usually precompiled with panic="unwind", rebuilding your crate with panic="abort" may not be enough to fix the problem
error[E0601]: `main` function not found in crate `attr_macro_panic`
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0601`.
Meta
rustc --version --verbose:
rustc 1.92.0 (ded5c06cf 2025-12-08)
binary: rustc
commit-hash: ded5c06cf21d2b93bffd5d884aa6e96934ee4234
commit-date: 2025-12-08
host: x86_64-unknown-linux-gnu
release: 1.92.0
LLVM version: 21.1.3
This error was discovered when running ./x ~.rs --bless in the UI test for #99478.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The reproduction uses auxiliary/panic-inducing.rs and attr-panic-macro.rs; first run the UI test for #99478 with ./x ~.rs --bless and inspect its expected diagnostics. Trace why the panic produces the follow-up errors, and consider the issue done when the test reports only the custom-attribute panic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100