Closed
Description
#59421 breaks some code generated by proc macros because quote converts integer to a tokenstream with a suffix.
Proc macro:
extern crate proc_macro;
use proc_macro::TokenStream;
use quote::quote;
#[proc_macro]
pub fn foo(_: TokenStream) -> TokenStream {
let index = 0;
TokenStream::from(quote! {
struct Foo(());
fn bar() {
let x = Foo(());
x.#index
}
})
}
Calling code:
foo!();
Error:
error: suffixes on a tuple index are invalid
--> src\lib.rs:3:1
|
3 | foo!();
| ^^^^^^^ invalid suffix `i32`
It can be avoided by using syn::Index::from
or proc_macro::Literal::*_unsuffixed
.
I have already fixed my library (taiki-e/pin-project@5f5cc35), but it can happen elsewhere.
Metadata
Metadata
Assignees
Labels
Area: The lexing & parsing of Rust source code to an ASTIssue: In need of a decision.High priorityRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.Performance or correctness regression from stable to beta.