-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
[let_chains
] Forbid let
inside parentheses
#95008
Conversation
2d0b50c
to
cdc53c2
Compare
r? @wesleywiser (rust-highfive has picked a reviewer for you, use r? to override) |
☔ The latest upstream changes (presumably #95403) made this pull request unmergeable. Please resolve the merge conflicts. |
cdc53c2
to
5740ae1
Compare
@rfcbot fcp merge Hi @rust-lang/lang -- I'd like to unblock let-chains. It seems to me that permitting parentheses to contain If I understand correctly, the result of this is that a if (
let Some(x) = option
) {
...
} but this would work if let Some(x) = option && something && let Some(z) = option { ... } as would this if let Some(x) = option && let Some(z) = option && (something || something_else) { ... } |
Team member @nikomatsakis has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
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! See this document for info about what commands tagged team members can give me. |
This sounds great; let's do it. We can always allow it in future, so personally I think we could even just merge the PR without waiting for an FCP. @rfcbot reviewed |
5740ae1
to
6ee3c47
Compare
The "currently" word was removed as demanded |
@rfcbot resolved currently Thank you! |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
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. |
Someone has to r+ |
@bors r+ |
📌 Commit 6ee3c47 has been approved by |
Rollup of 7 pull requests Successful merges: - rust-lang#95008 ([`let_chains`] Forbid `let` inside parentheses) - rust-lang#95801 (Replace RwLock by a futex based one on Linux) - rust-lang#95864 (Fix miscompilation of inline assembly with outputs in cases where we emit an invoke instead of call instruction.) - rust-lang#95894 (Fix formatting error in pin.rs docs) - rust-lang#95895 (Clarify str::from_utf8_unchecked's invariants) - rust-lang#95901 (Remove duplicate aliases for `check codegen_{cranelift,gcc}` and fix `build codegen_gcc`) - rust-lang#95927 (CI: do not compile libcore twice when performing LLVM PGO) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Parenthesizes are mostly a no-op in let chains, in other words, they are mostly ignored.
As seen above, such behavior can lead to confusion.
A proper fix or nested encapsulation would probably require research, time and a modified MIR graph so in this PR I simply denied any
let
inside parentheses. Non-let stuff are still allowed.It is worth noting that
let ...
is not an expression and the RFC did not mention this specific situation.cc @matthewjasper