Closed
Description
Given this procedural macro:
#![feature(proc_macro)]
extern crate proc_macro;
use proc_macro::*;
#[proc_macro_attribute]
pub fn doit(_: TokenStream, input: TokenStream) -> TokenStream {
input.into_iter().collect()
}
and this invocation:
#![feature(proc_macro)]
extern crate bar;
use bar::doit;
macro_rules! id {
($($t:tt)*) => ($($t)*)
}
#[doit]
id![static X: u32 = 'a';];
fn main() {}
It generates:
$ rustc +nightly bar.rs --crate-type proc-macro && rustc +nightly foo.rs -L .
error[E0308]: mismatched types
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
Not a great error message!
If the delimiters on the macro are changed from []
to ()
you get:
error[E0308]: mismatched types
--> foo.rs:11:21
|
11 | id!(static X: u32 = 'a';);
| ^^^ expected u32, found char
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
A much better error message!
This issue is forked off #50700