Tuple indexing regression · Issue #59553 · rust-lang/rust (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
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:
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.