mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-20 07:58:44 +00:00
Use match
on method args instead of if let
This commit is contained in:
parent
39eded7b05
commit
103200967e
1 changed files with 22 additions and 20 deletions
|
@ -65,7 +65,9 @@ impl LateLintPass<'_> for LinesFilterMapOk {
|
||||||
matches!(fm_method_str, "filter_map" | "flat_map" | "flatten") &&
|
matches!(fm_method_str, "filter_map" | "flat_map" | "flatten") &&
|
||||||
is_type_diagnostic_item(cx, cx.typeck_results().expr_ty_adjusted(fm_receiver), sym::IoLines)
|
is_type_diagnostic_item(cx, cx.typeck_results().expr_ty_adjusted(fm_receiver), sym::IoLines)
|
||||||
{
|
{
|
||||||
let lint = if let [fm_arg] = fm_args {
|
let lint = match fm_args {
|
||||||
|
[] => fm_method_str == "flatten",
|
||||||
|
[fm_arg] => {
|
||||||
match &fm_arg.kind {
|
match &fm_arg.kind {
|
||||||
// Detect `Result::ok`
|
// Detect `Result::ok`
|
||||||
ExprKind::Path(qpath) =>
|
ExprKind::Path(qpath) =>
|
||||||
|
@ -84,8 +86,8 @@ impl LateLintPass<'_> for LinesFilterMapOk {
|
||||||
},
|
},
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
fm_method_str == "flatten"
|
_ => false,
|
||||||
};
|
};
|
||||||
|
|
||||||
if lint {
|
if lint {
|
||||||
|
|
Loading…
Add table
Reference in a new issue