Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
0x2a-42 committed Jan 9, 2025
1 parent 3aab912 commit 34a09ba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/backend/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ impl RustOutput {
.as_bytes(),
)?;
if let Some(regex) = rule.regex(cst) {
if recursive.map_or(false, |recursive| {
if recursive.is_some_and(|recursive| {
recursive
.branches()
.iter()
Expand Down
8 changes: 4 additions & 4 deletions src/frontend/sema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl<'a> GeneralCheck<'a> {
let mut open = HashSet::new();
let mut created = HashMap::new();
let mut used = HashSet::new();
let left_rec = sema.recursive.get(&rule).map_or(false, |rec| {
let left_rec = sema.recursive.get(&rule).is_some_and(|rec| {
rec.branches()
.iter()
.any(|branch| matches!(branch, Recursion::Left(..) | Recursion::LeftRight(..)))
Expand Down Expand Up @@ -538,7 +538,7 @@ impl<'a> GeneralCheck<'a> {
&& (sema
.elision
.get(&alt_op.syntax())
.map_or(false, |elision| *elision != RuleNodeElision::None)
.is_some_and(|elision| *elision != RuleNodeElision::None)
|| rule.is_elided(cst))
{
diags.push(Diagnostic::elide_left_rec(&alt_op.span(cst)));
Expand Down Expand Up @@ -974,7 +974,7 @@ impl<'a> LL1Validator {
}
Regex::Paren(paren) => paren
.inner(cst)
.map_or(false, |inner| Self::has_predicate(cst, inner)),
.is_some_and(|inner| Self::has_predicate(cst, inner)),
_ => false,
}
}
Expand Down Expand Up @@ -1151,7 +1151,7 @@ impl<'a> LL1Validator {
if sema
.first_sets
.get(&name.syntax())
.map_or(false, |first| first.is_empty())
.is_some_and(|first| first.is_empty())
{
diags.push(Diagnostic::consume_tokens(&regex.span(cst)));
}
Expand Down
10 changes: 2 additions & 8 deletions src/ide/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ fn contains(span: &Span, pos: usize) -> bool {
pub fn lookup_node(cst: &Cst, node: NodeRef, pos: usize) -> Option<NodeRef> {
cst.children(node)
.filter(|node| matches!(cst.get(*node), Node::Rule(..)))
.find(|node| {
cst.get_span(*node)
.map_or(false, |span| contains(&span, pos))
})
.find(|node| cst.get_span(*node).is_some_and(|span| contains(&span, pos)))
.and_then(|node| lookup_node(cst, node, pos).or(Some(node)))
}
pub fn find_node<P: Fn(Rule) -> bool>(
Expand All @@ -31,10 +28,7 @@ pub fn find_node<P: Fn(Rule) -> bool>(
false
}
})
.find(|node| {
cst.get_span(*node)
.map_or(false, |span| contains(&span, pos))
})
.find(|node| cst.get_span(*node).is_some_and(|span| contains(&span, pos)))
.and_then(|node| find_node(cst, node, pos, pred).or(Some(node)))
}

Expand Down

0 comments on commit 34a09ba

Please sign in to comment.