Skip to content

Macro-generated macro can no longer be called #63651

Closed

Description

@dtolnay

The following crate no longer compiles as of the most recent nightly. The relevant commit range is f7af19c...bdfd698. Mentioning @petrochenkov @matthewjasper because #63535 sounds relevant – is this an intentional change?

Cargo.toml

[package]
name = "repro"
version = "0.0.0"
edition = "2018"
publish = false

[lib]
proc-macro = true

src/lib.rs

extern crate proc_macro;
use proc_macro::TokenStream;

#[proc_macro_derive(repro)]
pub fn d(_input: TokenStream) -> TokenStream {
    "macro_rules! m {()=>{}}".parse().unwrap()
}

src/main.rs

#[derive(repro::repro)]
pub struct S;

m!();

fn main() {}

$ cargo +stable check
   Compiling repro v0.0.0
    Finished dev [unoptimized + debuginfo] target(s) in 0.18s

$ cargo +nightly-2019-08-16 check
   Compiling repro v0.0.0
    Finished dev [unoptimized + debuginfo] target(s) in 0.18s

$ cargo +nightly-2019-08-17 check
   Compiling repro v0.0.0
error: cannot find macro `m!` in this scope
 --> src/main.rs:4:1
  |
4 | m!();
  | ^
  |
  = help: have you added the `#[macro_use]` on the module/import?

Activity

  1. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
    on Aug 17, 2019
  2. self-assigned this
    on Aug 17, 2019
  3. petrochenkov commented on Aug 17, 2019

    @petrochenkov
    Contributor

    I'll investigate.

  4. added
    C-bugCategory: This is a bug.
    A-resolveArea: Name/path resolution done by `rustc_resolve` specifically
    on Aug 17, 2019
  5. petrochenkov commented on Aug 17, 2019

    @petrochenkov
    Contributor

    Fixed in #63667.

  6. added a commit that references this issue on Aug 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to 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.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions