Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro-generated macro can no longer be called #63651

Closed
dtolnay opened this issue Aug 17, 2019 · 2 comments · Fixed by #63667
Closed

Macro-generated macro can no longer be called #63651

dtolnay opened this issue Aug 17, 2019 · 2 comments · Fixed by #63667
Assignees
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-resolve Area: Name/path resolution done by `rustc_resolve` specifically C-bug Category: This is a bug. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dtolnay
Copy link
Member

dtolnay commented Aug 17, 2019

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?
@dtolnay dtolnay added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Aug 17, 2019
@Centril Centril added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) labels Aug 17, 2019
@petrochenkov petrochenkov self-assigned this Aug 17, 2019
@petrochenkov
Copy link
Contributor

I'll investigate.

@petrochenkov
Copy link
Contributor

Fixed in #63667.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-resolve Area: Name/path resolution done by `rustc_resolve` specifically C-bug Category: This is a bug. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants