Skip to content

Commit ed77c31

Browse files
committed
refactor(linter_codegen): simplify matching "or" patterns (#13576)
Follow-on after #13138, as per [this comment](#13138 (comment)). Pure refactor. Break out of loop early on first failure, as following iterations have no effect.
1 parent 06f44a3 commit ed77c31

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

tasks/linter_codegen/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,12 @@ fn is_node_kind_call(expr: &Expr) -> bool {
269269
fn extract_variants_from_pat(pat: &Pat, out: &mut BTreeSet<String>) -> CollectionResult {
270270
match pat {
271271
Pat::Or(orpat) => {
272-
let mut result = CollectionResult::Complete;
273272
for p in &orpat.cases {
274273
if extract_variants_from_pat(p, out) == CollectionResult::Incomplete {
275-
result = CollectionResult::Incomplete;
274+
return CollectionResult::Incomplete;
276275
}
277276
}
278-
result
277+
CollectionResult::Complete
279278
}
280279
Pat::TupleStruct(ts) => {
281280
if let Some(variant) = astkind_variant_from_path(&ts.path) {

0 commit comments

Comments
 (0)