Open
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)
.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: Suggestions generated by the compiler applied by `cargo fix`Category: This is a bug.Diagnostics: A structured suggestion resulting in incorrect code.Relevant to the compiler team, which will review and decide on the PR/issue.