non-`#[macro_export]`'ed `macro_rules!` macros are impossible to disambiguate from built-in attributes in `use` declarations
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
macro_rules! warn { () => {} }
pub(crate) use warn;
fn main() { }
I expected it to compile.
Instead, it produces an error like this:
error[E0659]: `warn` is ambiguous
--> src/main.rs:3:16
|
3 | pub(crate) use warn;
| ^^^^ ambiguous name
|
= note: ambiguous because of a name conflict with a builtin attribute
= note: `warn` could refer to a built-in attribute
note: `warn` could also refer to the macro defined here
--> src/main.rs:1:1
|
1 | macro_rules! warn { () => {} }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
macro_rules are impossible to qualify it as self::warn or crate::warn or super::warn.
use r#warn doesn't do anything useful too.
The only thing you can do is something stupid like this:
macro_rules! warn_hack { ($($tt:tt)*) => { warn!($($tt)*) } }
pub(crate) use warn_hack as warn;
This will work, the fact that it works like that is why I consider this a bug.
Meta
Occurs on all versions with --edition 2018 or later.
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
Reproduce the reported macro_rules! and pub(crate) use warn example with the Rust 2018 or later edition, then compare it with the warn_hack workaround. Investigate the compiler's handling of macro imports that conflict with built-in attributes; done should include a supported disambiguation path and regression coverage for the reported cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100