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

Update lifetimes for pre-expansion validation #1668

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Oct 30, 2024

This updates the lifetime grammar to accommodate rust-lang/rust#126762 which switched to validating lifetimes pre-expansion. It also fixes a minor oversight where 'static was always grammatically allowed in a lifetime generic parameter (but is rejected semantically).

In summary, since this is subtle: Labels no longer parse '_ as valid. Thus, '_ is removed from the LIFETIME_OR_LABEL token. Since '_ is allowed by lifetimes, it has been moved to Lifetime.

Example:

// This is now an error in 1.81.
#[cfg(any())]
fn f() {
    '_: {
        break '_;
    }
}

and the oversight that was fixed (this was always allowed, but wasn't reflected in the reference grammar):

#[cfg(any())]
fn f<'static>() {}

cc @compiler-errors

@ehuss ehuss added this pull request to the merge queue Nov 5, 2024
Merged via the queue into rust-lang:master with commit ba3ca44 Nov 5, 2024
5 checks passed
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

Successfully merging this pull request may close these issues.

2 participants