4

Allow .. to be parsed as let initializer by RedDocMD · Pull Request #105701 · ru...

 1 year ago
source link: https://github.com/rust-lang/rust/pull/105701
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Allow .. to be parsed as let initializer #105701

Conversation

Contributor

@RedDocMD RedDocMD commented Dec 14, 2022

edited

.. and ..= are valid expressions, however when used in a let statement
it is not parsed.
Fixes #105634

Collaborator

rustbot commented Dec 14, 2022

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @lcnr (or someone else) soon.

Please see the contribution instructions for more information.

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

Dec 14, 2022

Member

Nilstrieb commented Dec 14, 2022

Thank you for your pull request! A small tip: you can write "Fixes #105634" in your description to clarify that you're fixing the issue and also because GitHub will then automatically close the issue when the PR is merged.

Contributor

lcnr commented Dec 14, 2022

r? compiler

lcnr

added the needs-fcp This change is insta-stable, so needs a completed FCP to proceed. label

Dec 14, 2022

src/test/ui/parser/issue-105634.rs

Outdated Show resolved

let expr = if self.token.is_range_seperator() {

self.parse_prefix_range_expr(None)

} else {

self.parse_prefix_expr(None)

};

Contributor

@CAD97 CAD97 Dec 14, 2022

My immediate expectation would be that parse_prefix_expr includes parse_prefix_range_expr. Are there any cases where we use parse_prefix_expr and we want prefix range expressions to be an error? If yes, make sure there's a test for that; if no, then it's probably better to move the range separator check/parse inside parse_prefix_expr.

I've not looked at this code much, but the reason it might matter is for other operator precedence reasons; e.g. what's the correct result of parsing +..1 or 1+..1.

Contributor

Author

@RedDocMD RedDocMD Dec 16, 2022

I think this separation of prefix range parsing from other prefix expr parsing is done to prevent expressions such as -..1 or !..1 from being parsed. Other unary operators can be stacked (may not be typeable), but you cannot have .. or ..= after a unary operator.

Contributor

cjgillot commented Dec 25, 2022

Thanks!
@bors r+

Contributor

bors commented Dec 25, 2022

pushpin Commit 4af9e6a has been approved by cjgillot

It is now in the queue for this repository.

bors

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

and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

labels

Dec 25, 2022

Contributor

bors commented Dec 25, 2022

hourglass Testing commit 4af9e6a with merge 300aa90...

Contributor

bors commented Dec 25, 2022

sunny Test successful - checks-actions
Approved by: cjgillot
Pushing 300aa90 to master...

bors

added the merged-by-bors This PR was explicitly merged by bors label

Dec 25, 2022

bors

merged commit 300aa90 into

rust-lang:master

Dec 25, 2022

11 checks passed

Collaborator

rust-timer commented Dec 25, 2022

Finished benchmarking commit (300aa90): comparison URL.

Overall result: white_check_mark improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions x
(primary)
- - 0
Regressions x
(secondary)
- - 0
Improvements white_check_mark
(primary)
-0.4% [-0.4%, -0.4%] 1
Improvements white_check_mark
(secondary)
-0.5% [-1.0%, -0.4%] 12
All xwhite_check_mark (primary) -0.4% [-0.4%, -0.4%] 1

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Assignees

cjgillot

Labels
merged-by-bors This PR was explicitly merged by bors needs-fcp This change is insta-stable, so needs a completed FCP to proceed. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects

None yet

Milestone

1.68.0

Development

Successfully merging this pull request may close these issues.

expected expression, found ..

9 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK