Skip to content

Regression in procedural macros emitting macro_rules macros #39889

Closed
@dtolnay

Description

@dtolnay

my-macro/src/lib.rs

extern crate proc_macro;
use proc_macro::TokenStream;

#[proc_macro_derive(Useless)]
pub fn demo(_input: TokenStream) -> TokenStream {
    let rules = r#"
        macro_rules! id {
            ($($tt:tt)*) => { $($tt)* };
        }
    "#;
    rules.parse().unwrap()
}

testing/src/main.rs

#[macro_use]
extern crate my_macro;

#[derive(Useless)]
struct _S;

pub fn main() {
    println!("{}", id!(true));
}

rustup run nightly-2017-02-13 cargo run

true

rustup run nightly-2017-02-16 cargo run

error: attempted to repeat an expression containing no syntax variables matched as repeating at this depth
 --> src/main.rs:4:10
  |
4 | #[derive(Useless)]
  |          ^^^^^^^

error: attempted to repeat an expression containing no syntax variables matched as repeating at this depth
 --> src/main.rs:4:10
  |
4 | #[derive(Useless)]
  |          ^^^^^^^

error: aborting due to 2 previous errors

cc @jseyfried who touched macro expansion recently

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions