Enforces some extra Clippy lints

pull/69/head
Tpt 4 years ago
parent 773bdb943e
commit 75a629860d
  1. 4
      lib/src/lib.rs
  2. 14
      lib/src/model/parser.rs
  3. 2
      lib/src/model/xsd/date_time.rs
  4. 5
      lib/src/sparql/parser.rs
  5. 2
      lib/src/sparql/plan.rs
  6. 18
      lib/src/store/memory.rs
  7. 2
      python/src/model.rs

@ -52,6 +52,10 @@
)]
#![doc(html_favicon_url = "https://raw.githubusercontent.com/oxigraph/oxigraph/master/logo.svg")]
#![doc(html_logo_url = "https://raw.githubusercontent.com/oxigraph/oxigraph/master/logo.svg")]
#![allow(
clippy::multiple_crate_versions, //TODO
clippy::rc_buffer //TODO: enforce
)]
#![warn(
clippy::cast_lossless,
clippy::cast_possible_truncation,

@ -80,28 +80,28 @@ impl FromStr for Literal {
/// assert_eq!(Literal::from_str("-122e+1").unwrap(), Literal::new_typed_literal("-122e+1", xsd::DOUBLE));
/// ```
fn from_str(s: &str) -> Result<Self, TermParseError> {
if s.starts_with('"') {
let mut value = String::with_capacity(s.len() - 2);
let mut chars = s[1..].chars();
if let Some(s) = s.strip_prefix('"') {
let mut value = String::with_capacity(s.len() - 1);
let mut chars = s.chars();
while let Some(c) = chars.next() {
match c {
'"' => {
let remain = chars.as_str();
return if remain.is_empty() {
Ok(Literal::new_simple_literal(value))
} else if remain.starts_with('@') {
} else if let Some(language) = remain.strip_prefix('@') {
Literal::new_language_tagged_literal(value, &remain[1..]).map_err(
|error| TermParseError {
kind: TermParseErrorKind::LanguageTag {
value: remain[1..].to_owned(),
value: language.to_owned(),
error,
},
},
)
} else if remain.starts_with("^^") {
} else if let Some(datatype) = remain.strip_prefix("^^") {
Ok(Literal::new_typed_literal(
value,
NamedNode::from_str(&remain[2..])?,
NamedNode::from_str(datatype)?,
))
} else {
Err(TermParseError::msg("Unexpected characters after a literal"))

@ -1155,7 +1155,7 @@ impl Timestamp {
Ok(Self {
timezone_offset: props.timezone_offset,
value: time_on_timeline(props).ok_or_else(|| DateTimeError {
value: time_on_timeline(props).ok_or(DateTimeError {
kind: DateTimeErrorKind::Overflow,
})?,
})

@ -421,10 +421,7 @@ impl ParserState {
}
fn new_aggregation(&mut self, agg: Aggregation) -> Result<Variable, &'static str> {
let aggregations = self
.aggregations
.last_mut()
.ok_or_else(|| "Unexpected aggregate")?;
let aggregations = self.aggregations.last_mut().ok_or("Unexpected aggregate")?;
Ok(aggregations
.iter()
.find_map(|(a, v)| if a == &agg { Some(v) } else { None })

@ -500,7 +500,7 @@ impl<I: StrId> EncodedTuple<I> {
self.inner.get(index).cloned().unwrap_or(None)
}
pub fn iter<'a>(&'a self) -> impl Iterator<Item = Option<EncodedTerm<I>>> + 'a {
pub fn iter(&self) -> impl Iterator<Item = Option<EncodedTerm<I>>> + '_ {
self.inner.iter().cloned()
}

@ -1033,13 +1033,13 @@ fn remove_from_quad_map<T: Eq + Hash>(quad_map: &mut QuadMap<T>, e1: &T, e2: &T,
}
}
fn option_set_flatten<'a, T: Clone>(i: Option<&'a HashSet<T>>) -> impl Iterator<Item = T> + 'a {
fn option_set_flatten<T: Clone>(i: Option<&HashSet<T>>) -> impl Iterator<Item = T> + '_ {
i.into_iter().flat_map(|s| s.iter().cloned())
}
fn option_pair_map_flatten<'a, T: Copy>(
i: Option<&'a HashMap<T, HashSet<T>>>,
) -> impl Iterator<Item = (T, T)> + 'a {
fn option_pair_map_flatten<T: Copy>(
i: Option<&HashMap<T, HashSet<T>>>,
) -> impl Iterator<Item = (T, T)> + '_ {
i.into_iter().flat_map(|kv| {
kv.iter().flat_map(|(k, vs)| {
let k = *k;
@ -1048,7 +1048,7 @@ fn option_pair_map_flatten<'a, T: Copy>(
})
}
fn triple_map_flatten<'a, T: Copy>(spo: &'a TripleMap<T>) -> impl Iterator<Item = (T, T, T)> + 'a {
fn triple_map_flatten<T: Copy>(spo: &TripleMap<T>) -> impl Iterator<Item = (T, T, T)> + '_ {
spo.iter().flat_map(|(s, po)| {
let s = *s;
po.iter().flat_map(move |(p, os)| {
@ -1058,9 +1058,9 @@ fn triple_map_flatten<'a, T: Copy>(spo: &'a TripleMap<T>) -> impl Iterator<Item
})
}
fn option_triple_map_flatten<'a, T: Copy>(
i: Option<&'a TripleMap<T>>,
) -> impl Iterator<Item = (T, T, T)> + 'a {
fn option_triple_map_flatten<T: Copy>(
i: Option<&TripleMap<T>>,
) -> impl Iterator<Item = (T, T, T)> + '_ {
i.into_iter().flat_map(|spo| {
spo.iter().flat_map(|(s, po)| {
let s = *s;
@ -1072,7 +1072,7 @@ fn option_triple_map_flatten<'a, T: Copy>(
})
}
fn quad_map_flatten<'a, T: Copy>(gspo: &'a QuadMap<T>) -> impl Iterator<Item = (T, T, T, T)> + 'a {
fn quad_map_flatten<T: Copy>(gspo: &QuadMap<T>) -> impl Iterator<Item = (T, T, T, T)> + '_ {
gspo.iter().flat_map(|(g, spo)| {
let g = *g;
spo.iter().flat_map(move |(s, po)| {

@ -654,7 +654,7 @@ impl PyQuad {
subject,
predicate,
object,
graph_name.unwrap_or_else(|| PyGraphName::DefaultGraph(PyDefaultGraph {})),
graph_name.unwrap_or(PyGraphName::DefaultGraph(PyDefaultGraph {})),
)
.into()
}

Loading…
Cancel
Save