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

[rustc_parse] Forbid lets in certain places #97295

Merged
merged 1 commit into from
Jun 26, 2022

Conversation

c410-f3r
Copy link
Contributor

Currently only forbids in locals to resolve #94927 (comment) but feel free to point any other places.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 22, 2022
@rust-highfive
Copy link
Collaborator

r? @compiler-errors

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 22, 2022
@compiler-errors
Copy link
Member

Sorry for taking so long to review.

I don't think this should be implemented like this. I think we should be explicitly adding code to allow let-chains in if and while (i.e. make them deny by default), and not exhaustively forbid them in certain places like the RHS of a let statement.

Even if this is the right approach, I think this current implementation is missing a lot of positions where we'd accidentally stabilize parsing let as an expression as discussed in #94927 (comment), for example:

#[cfg(ignore)]
fn foo() {
    let _ = f(let y = 1);
    |x| let 1 = 2;
    array[let x = y];
}

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

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

(whoops, should've left comment here)

@c410-f3r
Copy link
Contributor Author

Sorry for taking so long to review.

I don't think this should be implemented like this. I think we should be explicitly adding code to allow let-chains in if and while (i.e. make them deny by default), and not exhaustively forbid them in certain places like the RHS of a let statement.

Even if this is the right approach, I think this current implementation is missing a lot of positions where we'd accidentally stabilize parsing let as an expression as discussed in #94927 (comment), for example:

#[cfg(ignore)]
fn foo() {
    let _ = f(let y = 1);
    |x| let 1 = 2;
    array[let x = y];
}

Done. Thanks for the review

compiler/rustc_parse/src/parser/expr.rs Outdated Show resolved Hide resolved
compiler/rustc_parse/src/parser/expr.rs Outdated Show resolved Hide resolved
compiler/rustc_parse/src/parser/expr.rs Outdated Show resolved Hide resolved
compiler/rustc_parse/src/parser/expr.rs Show resolved Hide resolved
@compiler-errors compiler-errors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 6, 2022
@bors
Copy link
Contributor

bors commented Jun 15, 2022

☔ The latest upstream changes (presumably #97474) made this pull request unmergeable. Please resolve the merge conflicts.

@c410-f3r c410-f3r force-pushed the yet-another-let-chain branch 2 times, most recently from 862b590 to 5eeb48d Compare June 21, 2022 14:14
@c410-f3r
Copy link
Contributor Author

@rustbot label +S-waiting-on-review -S-waiting-on-author

If possible, I would like to tackle https://github.com/rust-lang/rust/pull/97295/files#diff-52ef6fde627bdaac8e79bcf67beac39ef4cd9a2a0bd0ff7e3ec69dd0ce74af94 and duplicated diagnostics in a following PR.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 21, 2022
@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member

Alright, this is a good first step then.

@bors r+

@bors
Copy link
Contributor

bors commented Jun 24, 2022

📌 Commit 1c460819c4dbd77dd22df0292a5b6052347245ef has been approved by compiler-errors

@bors 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 Jun 24, 2022
@bors
Copy link
Contributor

bors commented Jun 24, 2022

☔ The latest upstream changes (presumably #98447) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 24, 2022
@compiler-errors
Copy link
Member

@bors r- please fix the issues then i can re-approve

@c410-f3r
Copy link
Contributor Author

Done

@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jun 25, 2022

📌 Commit 7475867 has been approved by compiler-errors

@bors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 25, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 25, 2022
…ompiler-errors

[rustc_parse] Forbid `let`s in certain places

Currently only forbids in locals to resolve rust-lang#94927 (comment) but feel free to point any other places.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 25, 2022
…ompiler-errors

[rustc_parse] Forbid `let`s in certain places

Currently only forbids in locals to resolve rust-lang#94927 (comment) but feel free to point any other places.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jun 26, 2022
…ompiler-errors

[rustc_parse] Forbid `let`s in certain places

Currently only forbids in locals to resolve rust-lang#94927 (comment) but feel free to point any other places.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jun 26, 2022
…ompiler-errors

[rustc_parse] Forbid `let`s in certain places

Currently only forbids in locals to resolve rust-lang#94927 (comment) but feel free to point any other places.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 26, 2022
…ompiler-errors

[rustc_parse] Forbid `let`s in certain places

Currently only forbids in locals to resolve rust-lang#94927 (comment) but feel free to point any other places.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 26, 2022
…ompiler-errors

[rustc_parse] Forbid `let`s in certain places

Currently only forbids in locals to resolve rust-lang#94927 (comment) but feel free to point any other places.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 26, 2022
…askrgr

Rollup of 11 pull requests

Successful merges:

 - rust-lang#97140 (std: use an event-flag-based thread parker on SOLID)
 - rust-lang#97295 ([rustc_parse] Forbid `let`s in certain places)
 - rust-lang#97743 (make const_err show up in future breakage reports)
 - rust-lang#97908 (Stabilize NonZero* checked operations constness.)
 - rust-lang#98297 (Transform help popup into a pocket menu)
 - rust-lang#98428 (macros: use typed identifiers in diag and subdiag derive)
 - rust-lang#98528 (Respect --color when building rustbuild itself)
 - rust-lang#98535 (Add regression test for generic const in rustdoc)
 - rust-lang#98538 (Add a ui test for issue rust-lang#91883)
 - rust-lang#98540 (Add regression test for rust-lang#87558)
 - rust-lang#98541 (Update `std::alloc::System` doc example code style)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5b31271 into rust-lang:master Jun 26, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jun 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
Development

Successfully merging this pull request may close these issues.

6 participants