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

Rust: Include starting apostrophe in lifetime / loop label token #739

Merged
merged 2 commits into from Jan 29, 2023

Conversation

CosmicHorrorDev
Copy link
Contributor

Previously the apostrophe that would start lifetimes and loop labels would be considered an Operator while the ident after would be considered a NameAttribute (or NameBuiltin for _ or static). This change includes the apostrophe in the token instead

This did involve pulling out the (static|_) to make that match distinct. Let me know if you know of a better way to handle this

The test file with syntax highlighting for reference

struct Bar<'b>(&'b str);

struct Foo<'b, 'a: 'b>(&'a Bar<'b>);

fn foo<'some_name>(_: Bar<'_>, _: impl Iterator<Item = Bar<'static>> + 'static) {
    'im_1a_loop_label: loop {
        break 'im_a_loop_label;
    }

    // None of these should have lifetimes
    let _ = 'a';
    let _ = b'a';
    let _ = "
        'not_a_lifetime_or_label
    ";
}

Copy link
Owner

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it works, LGTM. Thanks!

@alecthomas alecthomas merged commit 0ea6503 into alecthomas:master Jan 29, 2023
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.

None yet

2 participants