Reject raw lifetime followed by ', like regular lifetimes do by compiler-errors · Pull Request #132341 · rust-lang/rust (original) (raw)

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

compiler-errors

See comment. We want to reject cases like 'r#long'id, which currently gets interpreted as a raw lifetime ('r#long) followed by a lifetime ('id). This could have alternative lexes, such as an overlong char literal ('r#long') followed by an identifier (id). To avoid committing to this in any case, let's reject the whole thing.

@mattheww, is this what you were looking for in rust-lang/reference#1603 (comment)? I'd say ignore the details about the specific error message (the fact that this gets reinterpreted as a char literal is 🤷), just that because this causes a lexer error we're effectively saving syntactical space like you wanted.

@compiler-errors

@rustbot

r? @chenyukang

rustbot has assigned @chenyukang.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

labels

Oct 30, 2024

@compiler-errors

Nominating as an easy decision because this is really new syntax and it saves space.

If we want to go through with this, I'd say we also beta nominate it because raw lifetimes are landing next edition, though I guess we could land them out of sync because I doubt anyone will begin relying on this obscure behavior of a somewhat obscure feature in 6 weeks.

@compiler-errors compiler-errors changed the titleReject raw lifetime followed by ' like lifetimes Reject raw lifetime followed by ', like regular lifetimes do

Oct 30, 2024

@mattheww

Yes, that's what I was thinking of.

I think #132341 (comment) has a typo, and should be saying

We want to reject cases like 'r#long'id

@joshtriplett joshtriplett added T-lang

Relevant to the language team

and removed T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

labels

Oct 30, 2024

@joshtriplett

@rfcbot

Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@joshtriplett joshtriplett added the T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

label

Oct 30, 2024

@tmandry

1 similar comment

@nikomatsakis

@traviscross

@rfcbot

🔔 This is now entering its final comment period, as per the review above. 🔔

@traviscross

@rustbot labels -I-lang-nominated

We discussed this in triage today, and as above, this seemed a clear call to us.

@apiraino

Beta backport accepted as per compiler team on Zulip, after it gets merged. A backport PR will be authored by the release team at the end of the current development cycle.

@rustbot label +beta-accepted

@rfcbot

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@compiler-errors

@bors

📌 Commit 1990f15 has been approved by chenyukang

It is now in the queue for this repository.

@bors bors added the S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

label

Nov 9, 2024

bors added a commit to rust-lang-ci/rust that referenced this pull request

Nov 9, 2024

@bors

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Nov 9, 2024

@rust-timer

Rollup merge of rust-lang#132341 - compiler-errors:raw-lt-prefix-id, r=chenyukang

Reject raw lifetime followed by ', like regular lifetimes do

See comment. We want to reject cases like 'r#long'id, which currently gets interpreted as a raw lifetime ('r#long) followed by a lifetime ('id). This could have alternative lexes, such as an overlong char literal ('r#long') followed by an identifier (id). To avoid committing to this in any case, let's reject the whole thing.

@mattheww, is this what you were looking for in rust-lang/reference#1603 (comment)? I'd say ignore the details about the specific error message (the fact that this gets reinterpreted as a char literal is 🤷), just that because this causes a lexer error we're effectively saving syntactical space like you wanted.

mati865 pushed a commit to mati865/rust that referenced this pull request

Nov 12, 2024

@matthiaskrgr @mati865

…r=chenyukang

Reject raw lifetime followed by ', like regular lifetimes do

See comment. We want to reject cases like 'r#long'id, which currently gets interpreted as a raw lifetime ('r#long) followed by a lifetime ('id). This could have alternative lexes, such as an overlong char literal ('r#long') followed by an identifier (id). To avoid committing to this in any case, let's reject the whole thing.

@mattheww, is this what you were looking for in rust-lang/reference#1603 (comment)? I'd say ignore the details about the specific error message (the fact that this gets reinterpreted as a char literal is 🤷), just that because this causes a lexer error we're effectively saving syntactical space like you wanted.

mati865 pushed a commit to mati865/rust that referenced this pull request

Nov 12, 2024

@bors @mati865

bors added a commit to rust-lang-ci/rust that referenced this pull request

Nov 15, 2024

@bors

bors added a commit to rust-lang-ci/rust that referenced this pull request

Nov 16, 2024

@bors

@mattheww

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Dec 1, 2024

@matthiaskrgr

…ebank

Only error raw lifetime followed by \' in edition 2021+

Fixes rust-lang#133479 cc rust-lang#132341

I think this fixes a purely theoretical regression since it only affects edition 2015 (who is using that?) and only in the very rare case of a raw lifetime followed immediately by a lifetime like 'r#a'r.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Dec 1, 2024

@matthiaskrgr

…ebank

Only error raw lifetime followed by \' in edition 2021+

Fixes rust-lang#133479 cc rust-lang#132341

I think this fixes a purely theoretical regression since it only affects edition 2015 (who is using that?) and only in the very rare case of a raw lifetime followed immediately by a lifetime like 'r#a'r.

mattheww added a commit to mattheww/lexeywan that referenced this pull request

Dec 1, 2024

@mattheww

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Dec 1, 2024

@rust-timer

Rollup merge of rust-lang#133482 - compiler-errors:raw-lt-tick, r=estebank

Only error raw lifetime followed by \' in edition 2021+

Fixes rust-lang#133479 cc rust-lang#132341

I think this fixes a purely theoretical regression since it only affects edition 2015 (who is using that?) and only in the very rare case of a raw lifetime followed immediately by a lifetime like 'r#a'r.

Labels

beta-accepted

Accepted for backporting to the compiler in the beta channel.

disposition-merge

This issue / PR is in PFCP or FCP with a disposition to merge it.

finished-final-comment-period

The final comment period is finished for this PR / Issue.

I-lang-easy-decision

Issue: The decision needed by the team is conjectured to be easy; this does not imply nomination

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

S-waiting-on-fcp

Status: PR is in FCP and is awaiting for FCP to complete.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

T-lang

Relevant to the language team

to-announce

Announce this issue on triage meeting