diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-17 17:22:32 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-17 17:22:32 +0100 |
commit | ce926aebc4461e38535047958c0b6f72b7a0c0ea (patch) | |
tree | 4b844e0681b459836bac22c34bee43e4dfa3dc5f /crates/ide_assists | |
parent | 3ae0c5911ab50ee209179ee4329b0551abe6fc48 (diff) | |
parent | 02d25ab60d2701ce71fe2dfaca36627ad902e229 (diff) |
Merge #9315
9315: Nest all the or-patterns! r=Veykril a=Veykril
`cargo +nightly clippy --fix -Z unstable-options --allow-dirty -- -A clippy::all -D clippy::unnested_or_patterns`
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/ide_assists')
-rw-r--r-- | crates/ide_assists/src/handlers/extract_function.rs | 2 | ||||
-rw-r--r-- | crates/ide_assists/src/handlers/inline_local_variable.rs | 55 | ||||
-rw-r--r-- | crates/ide_assists/src/tests.rs | 7 |
3 files changed, 34 insertions, 30 deletions
diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs index f2be091f4..7085a0c48 100644 --- a/crates/ide_assists/src/handlers/extract_function.rs +++ b/crates/ide_assists/src/handlers/extract_function.rs | |||
@@ -1384,7 +1384,7 @@ fn fix_param_usages(ctx: &AssistContext, params: &[Param], syntax: &SyntaxNode) | |||
1384 | for (param, usages) in usages_for_param { | 1384 | for (param, usages) in usages_for_param { |
1385 | for usage in usages { | 1385 | for usage in usages { |
1386 | match usage.syntax().ancestors().skip(1).find_map(ast::Expr::cast) { | 1386 | match usage.syntax().ancestors().skip(1).find_map(ast::Expr::cast) { |
1387 | Some(ast::Expr::MethodCallExpr(_)) | Some(ast::Expr::FieldExpr(_)) => { | 1387 | Some(ast::Expr::MethodCallExpr(_) | ast::Expr::FieldExpr(_)) => { |
1388 | // do nothing | 1388 | // do nothing |
1389 | } | 1389 | } |
1390 | Some(ast::Expr::RefExpr(node)) | 1390 | Some(ast::Expr::RefExpr(node)) |
diff --git a/crates/ide_assists/src/handlers/inline_local_variable.rs b/crates/ide_assists/src/handlers/inline_local_variable.rs index 2441dbb8b..945d28650 100644 --- a/crates/ide_assists/src/handlers/inline_local_variable.rs +++ b/crates/ide_assists/src/handlers/inline_local_variable.rs | |||
@@ -65,32 +65,35 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O | |||
65 | Some(u) => u, | 65 | Some(u) => u, |
66 | None => return Some(false), | 66 | None => return Some(false), |
67 | }; | 67 | }; |
68 | 68 | Some( | |
69 | Some(!matches!( | 69 | !(matches!( |
70 | (&initializer_expr, usage_parent), | 70 | initializer_expr, |
71 | (ast::Expr::CallExpr(_), _) | 71 | ast::Expr::CallExpr(_) |
72 | | (ast::Expr::IndexExpr(_), _) | 72 | | ast::Expr::IndexExpr(_) |
73 | | (ast::Expr::MethodCallExpr(_), _) | 73 | | ast::Expr::MethodCallExpr(_) |
74 | | (ast::Expr::FieldExpr(_), _) | 74 | | ast::Expr::FieldExpr(_) |
75 | | (ast::Expr::TryExpr(_), _) | 75 | | ast::Expr::TryExpr(_) |
76 | | (ast::Expr::RefExpr(_), _) | 76 | | ast::Expr::RefExpr(_) |
77 | | (ast::Expr::Literal(_), _) | 77 | | ast::Expr::Literal(_) |
78 | | (ast::Expr::TupleExpr(_), _) | 78 | | ast::Expr::TupleExpr(_) |
79 | | (ast::Expr::ArrayExpr(_), _) | 79 | | ast::Expr::ArrayExpr(_) |
80 | | (ast::Expr::ParenExpr(_), _) | 80 | | ast::Expr::ParenExpr(_) |
81 | | (ast::Expr::PathExpr(_), _) | 81 | | ast::Expr::PathExpr(_) |
82 | | (ast::Expr::BlockExpr(_), _) | 82 | | ast::Expr::BlockExpr(_) |
83 | | (ast::Expr::EffectExpr(_), _) | 83 | | ast::Expr::EffectExpr(_), |
84 | | (_, ast::Expr::CallExpr(_)) | 84 | ) || matches!( |
85 | | (_, ast::Expr::TupleExpr(_)) | 85 | usage_parent, |
86 | | (_, ast::Expr::ArrayExpr(_)) | 86 | ast::Expr::CallExpr(_) |
87 | | (_, ast::Expr::ParenExpr(_)) | 87 | | ast::Expr::TupleExpr(_) |
88 | | (_, ast::Expr::ForExpr(_)) | 88 | | ast::Expr::ArrayExpr(_) |
89 | | (_, ast::Expr::WhileExpr(_)) | 89 | | ast::Expr::ParenExpr(_) |
90 | | (_, ast::Expr::BreakExpr(_)) | 90 | | ast::Expr::ForExpr(_) |
91 | | (_, ast::Expr::ReturnExpr(_)) | 91 | | ast::Expr::WhileExpr(_) |
92 | | (_, ast::Expr::MatchExpr(_)) | 92 | | ast::Expr::BreakExpr(_) |
93 | )) | 93 | | ast::Expr::ReturnExpr(_) |
94 | | ast::Expr::MatchExpr(_) | ||
95 | )), | ||
96 | ) | ||
94 | }) | 97 | }) |
95 | .collect::<Option<_>>() | 98 | .collect::<Option<_>>() |
96 | .map(|b| (file_id, b)) | 99 | .map(|b| (file_id, b)) |
diff --git a/crates/ide_assists/src/tests.rs b/crates/ide_assists/src/tests.rs index 60cecd94c..29bd4a563 100644 --- a/crates/ide_assists/src/tests.rs +++ b/crates/ide_assists/src/tests.rs | |||
@@ -179,9 +179,10 @@ fn check(handler: Handler, before: &str, expected: ExpectedResult, assist_label: | |||
179 | "unresolved assist should not contain source changes" | 179 | "unresolved assist should not contain source changes" |
180 | ), | 180 | ), |
181 | (Some(_), ExpectedResult::NotApplicable) => panic!("assist should not be applicable!"), | 181 | (Some(_), ExpectedResult::NotApplicable) => panic!("assist should not be applicable!"), |
182 | (None, ExpectedResult::After(_)) | 182 | ( |
183 | | (None, ExpectedResult::Target(_)) | 183 | None, |
184 | | (None, ExpectedResult::Unresolved) => { | 184 | ExpectedResult::After(_) | ExpectedResult::Target(_) | ExpectedResult::Unresolved, |
185 | ) => { | ||
185 | panic!("code action is not applicable") | 186 | panic!("code action is not applicable") |
186 | } | 187 | } |
187 | (None, ExpectedResult::NotApplicable) => (), | 188 | (None, ExpectedResult::NotApplicable) => (), |