syn
syn copied to clipboard
Deny keyword lifetimes pre-expansion
As of nightly-2024-07-18, rustc has begin rejecting code such as the following, which used to parse successfully. https://github.com/rust-lang/rust/pull/126762
#[cfg(any())]
fn f<'ref>() {}
error: lifetimes cannot use keyword names
--> src/main.rs:2:6
|
2 | fn f<'ref>() {}
| ^^^^
If this is no longer valid Rust syntax, syn should reject it too.
Rustc still allows keyword lifetimes in macro input, so the Parse impl for syn::Lifetime probably needs to continue to allow them too.
fn main() {
println!("{}", stringify!('ref));
}
But syntax tree uses of Lifetime, such as in GenericParam, can begin rejecting these.