Suggested fix for "cannot find macro `...` in this scope" does not compile
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=a095133990477eb48c9b42343e5593f4
fn main() {}
// STEP 1: Try to compile, will fail with "error: cannot find macro `nothing` in this scope".
// STEP 2: Uncomment line 18 as per suggestion.
// STEP 3: Try to compile, will fail with "macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths".
// STEP 4: Comment line 9.
mod a {
#[rustfmt::skip]
#[macro_export]
macro_rules! nothing {
() => {};
}
}
mod b {
fn foo() {
//use crate::nothing;
nothing!();
}
}
I expected to see this happen: Using a suggestion "just works".
Instead, this happened: Unexpected and even more confusing error message caused because of #98291.
Meta
Tested on playground with 1.84.0 (stable) and 1.86.0-nightly (2025-01-26 f85c6de55206dbee5ffe).
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
Start by reproducing the linked Rust Playground example on the stated stable and nightly versions, then read issue #98291 for the related behavior. Trace the suggested use crate::nothing import and the macro_export definition in the example; done means the diagnostic suggestion no longer leads directly to the reported absolute-path error.
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
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100