-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Description
#![feature(decl_macro)]
macro_rules! inner {
() => {}
}
macro outer() {
inner!();
}
outer!();This code results in this confusing and completely incorrect error message:
error: cannot find macro `inner` in this scope
--> src/lib.rs:10:5
|
10 | inner!();
| ^^^^^ consider moving the definition of `inner` before this call
...
15 | outer!();
| -------- in this macro invocation
|
note: a macro with the same name exists, but it appears later
--> src/lib.rs:5:14
|
5 | macro_rules! inner {
| ^^^^^
= note: this error originates in the macro `outer` (in Nightly builds, run with -Z macro-backtrace for more info)Obviously, the definition of inner doesn't "appear later" than the definition of outer. In fact, the problem has nothing to do with definition order. The real fix is to add use inner; anywhere after the definition of inner.
(As a side note, I don't know if this is the intended behavior of macros 2.0, or a bug / current limitation of the nightly feature)
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.