Skip to content

Commit

Permalink
chore(core): rename check_destructuring_match function
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLucqs committed Aug 12, 2024
1 parent a209b17 commit 5bd9a81
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions crates/cairo-lint-core/src/lints/single_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ fn tuple_expr_in_block_expr(
None
}
}
pub fn check_destruct_match(db: &dyn SyntaxGroup, match_expr: &ExprMatch, diagnostics: &mut Vec<PluginDiagnostic>) {

pub fn check_single_match(db: &dyn SyntaxGroup, match_expr: &ExprMatch, diagnostics: &mut Vec<PluginDiagnostic>) {
let arms = match_expr.arms(db).elements(db);
let mut is_single_armed = false;
let mut is_destructuring = false;
Expand All @@ -43,12 +44,8 @@ pub fn check_destruct_match(db: &dyn SyntaxGroup, match_expr: &ExprMatch, diagno
is_single_armed =
tuple_expr.is_some_and(|list| list.expressions(db).elements(db).is_empty()) || is_single_armed;
}

Pattern::Enum(pat) => {
is_destructuring = !pat.pattern(db).as_syntax_node().get_text(db).is_empty();
}
Pattern::Struct(pat) => {
is_destructuring = !pat.as_syntax_node().get_text(db).is_empty();
Pattern::Enum(_) | Pattern::Struct(_) => {
is_destructuring = true;
}
_ => (),
};
Expand Down
2 changes: 1 addition & 1 deletion crates/cairo-lint-core/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl AnalyzerPlugin for CairoLint {
let descendants = func.as_syntax_node().descendants(db.upcast());
for descendant in descendants.into_iter() {
match descendant.kind(db.upcast()) {
SyntaxKind::ExprMatch => single_match::check_destruct_match(
SyntaxKind::ExprMatch => single_match::check_single_match(
db.upcast(),
&ExprMatch::from_syntax_node(db.upcast(), descendant),
&mut diags,
Expand Down

0 comments on commit 5bd9a81

Please sign in to comment.