-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[manual_flatten
]: Fix with nested Some
or Ok
pattern
#14846
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
Conversation
manual_flatten
] with nested Some
or Ok
patternmanual_flatten
]: Fix with nested Some
or Ok
pattern
r? @Alexendoo rustbot has assigned @Alexendoo. Use |
@@ -39,9 +39,13 @@ pub(super) fn check<'tcx>( | |||
&& msrv.meets(cx, msrvs::ITER_FLATTEN) | |||
{ | |||
let if_let_type = if some_ctor { "Some" } else { "Ok" }; | |||
let has_nested_tuple_struct = contains_nested_tuple_struct(pats); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would apply to other refutable patterns too so it can use https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.is_refutable.html
e.g. if let Some((x, 1)) = y { ... }
tests/ui/manual_flatten.stderr
Outdated
help: ...and remove the outer `Some` variant in the for loop | ||
--> tests/ui/manual_flatten.rs:131:9 | ||
| | ||
LL | / if let Some((_, Some(n))) = n { | ||
LL | | println!("{}", n); | ||
LL | | } | ||
| |_________^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be better to not lint these cases, it doesn't make it shorter or reduce the nesting level
Thank you for your review. |
Yeah that's great thanks, if you could squash the commits then it looks good to go |
This comment has been minimized.
This comment has been minimized.
Thank you for your review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
changelog: [
manual_flatten
]: fix with nestedSome
orOk
patternfixes #6776