-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Open
Labels
A-proc-macrosArea: Procedural macrosArea: Procedural macrosC-bugCategory: This is a bug.Category: This is a bug.F-proc_macro_quote`#![feature(proc_macro_quote)]``#![feature(proc_macro_quote)]`T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
A constant N
can be interpolated as $N
inside quote, but not inside a repetition. I believe this should be supported.
#![feature(proc_macro_quote)]
use proc_macro::{quote, TokenStream};
const N: usize = 8;
#[proc_macro]
pub fn repro(_input: TokenStream) -> TokenStream {
let ok = '?';
let array = ['0', '1', '2'];
let tokens = quote! {
// Okay
... $ok $N ...
// Okay
$($ok $array)*
// Fail
$($N $array)*
};
eprintln!("{}", tokens);
TokenStream::new()
}
error[E0530]: let bindings cannot shadow constants
--> src/lib.rs:19:12
|
5 | const N: usize = 8;
| ------------------- the constant `N` is defined here
...
19 | $($N $array)*
| ^ cannot be named the same as a constant
Expected output:
... '?' 8usize ... '?' '0' '?' '1' '?' '2' 8usize '0' 8usize '1' 8usize '2'
- Tracking issue: Tracking issue for the
quote!
macro inproc_macro
#54722
Metadata
Metadata
Assignees
Labels
A-proc-macrosArea: Procedural macrosArea: Procedural macrosC-bugCategory: This is a bug.Category: This is a bug.F-proc_macro_quote`#![feature(proc_macro_quote)]``#![feature(proc_macro_quote)]`T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.