WIP: Makes clippy happy

rules
Tpt 2 years ago
parent ea1ec3ede0
commit ecdc106fd5
  1. 10
      lib/spargebra/src/rule.rs
  2. 24
      lib/sparopt/src/algebra.rs
  3. 3
      lib/sparopt/src/reasoning.rs
  4. 11
      testsuite/src/sparql_evaluator.rs

@ -20,8 +20,7 @@ impl RuleSet {
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
pub fn to_sse(&self) -> String {
let mut buffer = String::new();
self.fmt_sse(&mut buffer)
.expect("Unexpected error during SSE formatting");
self.fmt_sse(&mut buffer).unwrap();
buffer
}
@ -84,8 +83,7 @@ impl Rule {
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
pub fn to_sse(&self) -> String {
let mut buffer = String::new();
self.fmt_sse(&mut buffer)
.expect("Unexpected error during SSE formatting");
self.fmt_sse(&mut buffer).unwrap();
buffer
}
@ -110,11 +108,11 @@ impl Rule {
impl fmt::Display for Rule {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "IF {{ ")?;
for triple in self.body.iter() {
for triple in &self.body {
write!(f, "{triple} . ")?;
}
write!(f, "}} THEN {{ ")?;
for triple in self.head.iter() {
for triple in &self.head {
write!(f, "{triple} . ")?;
}
write!(f, "}}")

@ -1371,7 +1371,7 @@ impl FixedPointGraphPattern {
let mut constant = Self::empty();
let mut recursive = Self::empty();
for child in children {
if child.is_recursion_used(&id) {
if child.is_recursion_used(id) {
recursive = Self::union(recursive, child);
} else {
constant = Self::union(constant, child);
@ -1388,7 +1388,7 @@ impl FixedPointGraphPattern {
}
}
fn is_recursion_used(&self, id: &FixedPointId) -> bool {
fn is_recursion_used(&self, id: FixedPointId) -> bool {
match self {
Self::QuadPattern { .. } | Self::Values { .. } => false,
Self::Filter { inner, .. }
@ -1403,13 +1403,13 @@ impl FixedPointGraphPattern {
recursive,
..
} => Self::is_recursion_used(constant, id) || Self::is_recursion_used(recursive, id),
Self::FixedPointEntry(tid) => id == tid,
Self::FixedPointEntry(tid) => id == *tid,
}
}
pub(crate) fn lookup_used_variables(&self, callback: &mut impl FnMut(&Variable)) {
match self {
FixedPointGraphPattern::QuadPattern {
Self::QuadPattern {
subject,
predicate,
object,
@ -1424,34 +1424,34 @@ impl FixedPointGraphPattern {
callback(v);
}
}
FixedPointGraphPattern::Join { left, right } => {
Self::Join { left, right } => {
left.lookup_used_variables(callback);
right.lookup_used_variables(callback);
}
FixedPointGraphPattern::Filter { inner, .. } => {
Self::Filter { inner, .. } => {
inner.lookup_used_variables(callback);
// TODO: we assume all expression variables are bound
}
FixedPointGraphPattern::Union { inner } => {
Self::Union { inner } => {
for inner in inner {
inner.lookup_used_variables(callback);
}
}
FixedPointGraphPattern::Extend {
Self::Extend {
inner, variable, ..
} => {
inner.lookup_used_variables(callback);
callback(variable);
// TODO: we assume all expression variables are bound
}
FixedPointGraphPattern::Values { variables, .. }
| FixedPointGraphPattern::Project { variables, .. }
| FixedPointGraphPattern::FixedPoint { variables, .. } => {
Self::Values { variables, .. }
| Self::Project { variables, .. }
| Self::FixedPoint { variables, .. } => {
for v in variables {
callback(v);
}
}
FixedPointGraphPattern::FixedPointEntry(_) => {
Self::FixedPointEntry(_) => {
//TODO
}
}

@ -1009,7 +1009,7 @@ impl QueryRewriter {
}]),
},
GroundTermPattern::Literal(from) => match to {
GroundTermPattern::NamedNode(_) => None,
GroundTermPattern::NamedNode(_) | GroundTermPattern::Triple(_) => None,
GroundTermPattern::Literal(to) => {
if from == to {
Some(Vec::new())
@ -1017,7 +1017,6 @@ impl QueryRewriter {
None
}
}
GroundTermPattern::Triple(_) => None,
GroundTermPattern::Variable(to) => Some(vec![Replacement::ConstToVar {
from: from.into(),
to,

@ -152,6 +152,12 @@ fn result_syntax_check(test: &Test, format: QueryResultsFormat) -> Result<()> {
}
fn evaluate_evaluation_test(test: &Test) -> Result<()> {
enum Mode {
Base,
WithoutOptimizer,
WithInferenceRules,
}
let store = Store::new()?;
if let Some(data) = &test.data {
load_dataset_to_store(data, &store)?;
@ -198,11 +204,6 @@ fn evaluate_evaluation_test(test: &Test) -> Result<()> {
false
};
enum Mode {
Base,
WithoutOptimizer,
WithInferenceRules,
}
for mode in [Mode::Base, Mode::WithoutOptimizer, Mode::WithInferenceRules] {
let options = match mode {
Mode::Base => options.clone(),

Loading…
Cancel
Save