Use let...else instead of match foo { ... _ => return }; and if let ... else return#148837
Use let...else instead of match foo { ... _ => return }; and if let ... else return#148837bors merged 3 commits intorust-lang:mainfrom
let...else instead of match foo { ... _ => return }; and if let ... else return#148837Conversation
|
r? @wesleywiser rustbot has assigned @wesleywiser. Use |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Maybe skip this for now to avoid conflicts with #148481?
|
do we have a style check for this? |
|
@chenyukang there's a pedantic clippy lint that we could enable: https://rust-lang.github.io/rust-clippy/master/index.html#/let-else |
There was a problem hiding this comment.
Thanks for taking time on this, looks good on compiler side, would this reasonable to split compiler and library parts? I'm not sure if I privileged enough to review the library part
There is some places that looks better with the if let guard feature to remove nesting
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
f61284d to
9c1998b
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
||
| // tidy-alphabetical-start | ||
| #![cfg_attr(bootstrap, feature(array_windows))] | ||
| #![deny(clippy::manual_let_else)] |
There was a problem hiding this comment.
let's not add this lint anywhere yet, I think CI will never stop complain about it :D
There was a problem hiding this comment.
I'm finding them instructive :)
There was a problem hiding this comment.
ah, so feel free to «r=me» once CI passed
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #149645) made this pull request unmergeable. Please resolve the merge conflicts. |
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@bors r=Kivooeo |
Use `let...else` instead of `match foo { ... _ => return };` and `if let ... else return`
Rollup of 11 pull requests Successful merges: - #145278 (Update `rustc_codegen_gcc` rotate operation document) - #148825 (Add SystemTime::{MIN, MAX}) - #148837 (Use `let...else` instead of `match foo { ... _ => return };` and `if let ... else return`) - #149177 (Add proper suggestion for associated function with unknown field) - #149843 (Inherit attributes in delegation) - #149860 (Fix: Prevent macro-expanded extern crates from shadowing extern arguments) - #149874 (Weak for Arc pointer is marked as DynSend/DynSync) - #149903 (Remove unused code in `cfg_old`) - #149911 (bootstrap: Don't pass an unused `--color` to compiletest) - #149916 (Add a sanity check in case of any duplicate nodes) - #149924 (`declare_lint_pass` for `INLINE_ALWAYS_MISMATCHING_TARGET_FEATURES`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 10 pull requests Successful merges: - #145278 (Update `rustc_codegen_gcc` rotate operation document) - #148837 (Use `let...else` instead of `match foo { ... _ => return };` and `if let ... else return`) - #149177 (Add proper suggestion for associated function with unknown field) - #149843 (Inherit attributes in delegation) - #149860 (Fix: Prevent macro-expanded extern crates from shadowing extern arguments) - #149874 (Weak for Arc pointer is marked as DynSend/DynSync) - #149903 (Remove unused code in `cfg_old`) - #149911 (bootstrap: Don't pass an unused `--color` to compiletest) - #149916 (Add a sanity check in case of any duplicate nodes) - #149924 (`declare_lint_pass` for `INLINE_ALWAYS_MISMATCHING_TARGET_FEATURES`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #148837 - estebank:let-else, r=Kivooeo Use `let...else` instead of `match foo { ... _ => return };` and `if let ... else return`
Use `let...else` instead of `match foo { ... _ => return };` and `if let ... else return`
Use `let`...`else` instead of `match foo { ... _ => return };` and `if let ... else return` in std
Split off rust-lang/rust#148837.
Rollup of 10 pull requests Successful merges: - rust-lang/rust#145278 (Update `rustc_codegen_gcc` rotate operation document) - rust-lang/rust#148837 (Use `let...else` instead of `match foo { ... _ => return };` and `if let ... else return`) - rust-lang/rust#149177 (Add proper suggestion for associated function with unknown field) - rust-lang/rust#149843 (Inherit attributes in delegation) - rust-lang/rust#149860 (Fix: Prevent macro-expanded extern crates from shadowing extern arguments) - rust-lang/rust#149874 (Weak for Arc pointer is marked as DynSend/DynSync) - rust-lang/rust#149903 (Remove unused code in `cfg_old`) - rust-lang/rust#149911 (bootstrap: Don't pass an unused `--color` to compiletest) - rust-lang/rust#149916 (Add a sanity check in case of any duplicate nodes) - rust-lang/rust#149924 (`declare_lint_pass` for `INLINE_ALWAYS_MISMATCHING_TARGET_FEATURES`) r? `@ghost` `@rustbot` modify labels: rollup
Use `let`...`else` instead of `match foo { ... _ => return };` and `if let ... else return` in std
Split off rust-lang/rust#148837.
Rollup of 10 pull requests Successful merges: - rust-lang/rust#145278 (Update `rustc_codegen_gcc` rotate operation document) - rust-lang/rust#148837 (Use `let...else` instead of `match foo { ... _ => return };` and `if let ... else return`) - rust-lang/rust#149177 (Add proper suggestion for associated function with unknown field) - rust-lang/rust#149843 (Inherit attributes in delegation) - rust-lang/rust#149860 (Fix: Prevent macro-expanded extern crates from shadowing extern arguments) - rust-lang/rust#149874 (Weak for Arc pointer is marked as DynSend/DynSync) - rust-lang/rust#149903 (Remove unused code in `cfg_old`) - rust-lang/rust#149911 (bootstrap: Don't pass an unused `--color` to compiletest) - rust-lang/rust#149916 (Add a sanity check in case of any duplicate nodes) - rust-lang/rust#149924 (`declare_lint_pass` for `INLINE_ALWAYS_MISMATCHING_TARGET_FEATURES`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 10 pull requests Successful merges: - rust-lang/rust#145278 (Update `rustc_codegen_gcc` rotate operation document) - rust-lang/rust#148837 (Use `let...else` instead of `match foo { ... _ => return };` and `if let ... else return`) - rust-lang/rust#149177 (Add proper suggestion for associated function with unknown field) - rust-lang/rust#149843 (Inherit attributes in delegation) - rust-lang/rust#149860 (Fix: Prevent macro-expanded extern crates from shadowing extern arguments) - rust-lang/rust#149874 (Weak for Arc pointer is marked as DynSend/DynSync) - rust-lang/rust#149903 (Remove unused code in `cfg_old`) - rust-lang/rust#149911 (bootstrap: Don't pass an unused `--color` to compiletest) - rust-lang/rust#149916 (Add a sanity check in case of any duplicate nodes) - rust-lang/rust#149924 (`declare_lint_pass` for `INLINE_ALWAYS_MISMATCHING_TARGET_FEATURES`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 10 pull requests Successful merges: - rust-lang/rust#145278 (Update `rustc_codegen_gcc` rotate operation document) - rust-lang/rust#148837 (Use `let...else` instead of `match foo { ... _ => return };` and `if let ... else return`) - rust-lang/rust#149177 (Add proper suggestion for associated function with unknown field) - rust-lang/rust#149843 (Inherit attributes in delegation) - rust-lang/rust#149860 (Fix: Prevent macro-expanded extern crates from shadowing extern arguments) - rust-lang/rust#149874 (Weak for Arc pointer is marked as DynSend/DynSync) - rust-lang/rust#149903 (Remove unused code in `cfg_old`) - rust-lang/rust#149911 (bootstrap: Don't pass an unused `--color` to compiletest) - rust-lang/rust#149916 (Add a sanity check in case of any duplicate nodes) - rust-lang/rust#149924 (`declare_lint_pass` for `INLINE_ALWAYS_MISMATCHING_TARGET_FEATURES`) r? `@ghost` `@rustbot` modify labels: rollup
No description provided.