Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deny keyword lifetimes pre-expansion #1708

Open
dtolnay opened this issue Jul 17, 2024 · 1 comment
Open

Deny keyword lifetimes pre-expansion #1708

dtolnay opened this issue Jul 17, 2024 · 1 comment

Comments

@dtolnay
Copy link
Owner

dtolnay commented Jul 17, 2024

As of nightly-2024-07-18, rustc has begin rejecting code such as the following, which used to parse successfully. rust-lang/rust#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.

@dtolnay
Copy link
Owner Author

dtolnay commented Oct 24, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant