Skip to content

Commit

Permalink
chore: apply clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Jul 16, 2024
1 parent eeab033 commit 3404e31
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions crates/grit-pattern-matcher/src/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ pub trait Binding<'a, Q: QueryContext>: Clone + std::fmt::Debug + PartialEq + Si
if let Some(binding) = resolved.get_last_binding() {
Ok(binding.clone())
} else {
return Err(GritPatternError::new(
Err(GritPatternError::new(
"cannot create binding from pattern without binding",
));
))
}
}

Expand Down
12 changes: 6 additions & 6 deletions crates/grit-pattern-matcher/src/pattern/accessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ impl<Q: QueryContext> Accessor<Q> {
Some(PatternOrResolved::Resolved(resolved)) => match resolved.get_map() {
Some(m) => Ok(m.get(key.as_ref()).map(PatternOrResolved::Resolved)),
None => {
return Err(GritPatternError::new(
Err(GritPatternError::new(
"left side of an accessor must be a map",
))
}
},
Some(_) => {
return Err(GritPatternError::new(
Err(GritPatternError::new(
"left side of an accessor must be a map",
))
}
Expand All @@ -93,13 +93,13 @@ impl<Q: QueryContext> Accessor<Q> {
Some(PatternOrResolvedMut::Resolved(resolved)) => match resolved.get_map_mut() {
Some(m) => Ok(m.get_mut(key.as_ref()).map(PatternOrResolvedMut::Resolved)),
None => {
return Err(GritPatternError::new(
Err(GritPatternError::new(
"left side of an accessor must be a map",
))
}
},
Some(_) => {
return Err(GritPatternError::new(
Err(GritPatternError::new(
"left side of an accessor must be a map",
))
}
Expand All @@ -124,9 +124,9 @@ impl<Q: QueryContext> Accessor<Q> {
m.insert(key.to_string(), value);
Ok(true)
} else {
return Err(GritPatternError::new(
Err(GritPatternError::new(
"accessor can only mutate a resolved map",
));
))
}
}
Some(_) => Err(GritPatternError::new(
Expand Down
12 changes: 6 additions & 6 deletions crates/grit-pattern-matcher/src/pattern/accumulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ impl<Q: QueryContext> Matcher<Q> for Accumulate<Q> {
base.extend(append, &mut state.effects, context.language())?;
Ok(true)
} else {
return Err(GritPatternError::new(format!(
Err(GritPatternError::new(format!(
"Variable {} is not bound",
state.bindings[var.scope].last().unwrap()[var.index].name
)));
)))
}
} else {
let resolved = if !self.left.execute(context_node, state, context, logs)? {
Expand Down Expand Up @@ -120,15 +120,15 @@ impl<Q: QueryContext> Evaluator<Q> for Accumulate<Q> {
ret_val: None,
})
} else {
return Err(GritPatternError::new(format!(
Err(GritPatternError::new(format!(
"Variable {} is not bound",
state.bindings[var.scope].last().unwrap()[var.index].name
)));
)))
}
} else {
return Err(GritPatternError::new(
Err(GritPatternError::new(
"Insert side-conditions must have variable on left-hand side",
));
))
}
}
}
12 changes: 6 additions & 6 deletions crates/grit-pattern-matcher/src/pattern/list_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<Q: QueryContext> ListIndex<Q> {
}
}
Some(s) => {
return Err(GritPatternError::new(format!(
Err(GritPatternError::new(format!(
"left side of a listIndex must be a list but got {:?}",
s
)))
Expand Down Expand Up @@ -127,13 +127,13 @@ impl<Q: QueryContext> ListIndex<Q> {
.get_list_item_at_mut(index)
.map(PatternOrResolvedMut::Resolved))
} else {
return Err(GritPatternError::new(
Err(GritPatternError::new(
"left side of a listIndex must be a list",
));
))
}
}
Some(s) => {
return Err(GritPatternError::new(format!(
Err(GritPatternError::new(format!(
"left side of a listIndex must be a list but got {:?}",
s
)))
Expand All @@ -157,13 +157,13 @@ impl<Q: QueryContext> ListIndex<Q> {
resolved.set_list_item_at_mut(index, value)
}
Some(_) => {
return Err(GritPatternError::new(
Err(GritPatternError::new(
"accessor can only mutate a resolved list",
))
}
},
ListOrContainer::List(_) => {
return Err(GritPatternError::new("cannot mutate a list literal"))
Err(GritPatternError::new("cannot mutate a list literal"))
}
}
}
Expand Down

0 comments on commit 3404e31

Please sign in to comment.