Skip to content

hygiene: cannot find macro foo! in this scope #63685

Closed
@tesuji

Description

@tesuji

This code (playpen) compiles on stable but not on nightly and beta:

macro_rules! foo {
    () => {
        "foo"
    };
}

macro_rules! bar {
    () => {
        foo!()
    };
}

fn main() {
    println!(bar!());
}

Standard Error

   Compiling playground v0.0.1 (/playground)
error: cannot find macro `foo!` in this scope
 --> src/main.rs:9:9
  |
9 |         foo!()
  |         ^^^

warning: unused macro definition
 --> src/main.rs:1:1
  |
1 | / macro_rules! foo {
2 | |     () => {
3 | |         "foo"
4 | |     };
5 | | }
  | |_^
  |
  = note: `#[warn(unused_macros)]` on by default

error: aborting due to previous error

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

Edit: Removed concat! macro

Originally posted by @lzutao in #63460 (comment)

Metadata

Metadata

Assignees

Labels

A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions