Fixes some new clippy warnings

pull/190/head
Tpt 3 years ago
parent 7d58f451bd
commit 32d3f0782b
  1. 8
      js/src/model.rs
  2. 2
      lib/oxrdf/src/dataset.rs
  3. 4
      lib/oxrdf/src/parser.rs
  4. 6
      lib/spargebra/src/parser.rs
  5. 4
      lib/src/sparql/mod.rs
  6. 4
      lib/src/storage/backend/rocksdb.rs
  7. 2
      server/src/main.rs
  8. 4
      testsuite/src/files.rs

@ -34,16 +34,16 @@ pub fn literal(
language_or_datatype: &JsValue, language_or_datatype: &JsValue,
) -> Result<JsLiteral, JsValue> { ) -> Result<JsLiteral, JsValue> {
if language_or_datatype.is_null() || language_or_datatype.is_undefined() { if language_or_datatype.is_null() || language_or_datatype.is_undefined() {
Ok(Literal::new_simple_literal(value.unwrap_or_else(String::new)).into()) Ok(Literal::new_simple_literal(value.unwrap_or_default()).into())
} else if language_or_datatype.is_string() { } else if language_or_datatype.is_string() {
Ok(Literal::new_language_tagged_literal( Ok(Literal::new_language_tagged_literal(
value.unwrap_or_else(String::new), value.unwrap_or_default(),
language_or_datatype.as_string().unwrap_or_else(String::new), language_or_datatype.as_string().unwrap_or_default(),
) )
.map_err(to_err)? .map_err(to_err)?
.into()) .into())
} else if let JsTerm::NamedNode(datatype) = FROM_JS.with(|c| c.to_term(language_or_datatype))? { } else if let JsTerm::NamedNode(datatype) = FROM_JS.with(|c| c.to_term(language_or_datatype))? {
Ok(Literal::new_typed_literal(value.unwrap_or_else(String::new), datatype).into()) Ok(Literal::new_typed_literal(value.unwrap_or_default(), datatype).into())
} else { } else {
Err(format_err!("The literal datatype should be a NamedNode")) Err(format_err!("The literal datatype should be a NamedNode"))
} }

@ -725,7 +725,7 @@ impl Dataset {
b b
}) })
}) })
.unwrap_or_else(Vec::new) .unwrap_or_default()
} else { } else {
self.label(hash) self.label(hash)
} }

@ -160,7 +160,7 @@ fn read_blank_node(s: &str) -> Result<(BlankNode, &str), TermParseError> {
if let Some(remain) = s.strip_prefix("_:") { if let Some(remain) = s.strip_prefix("_:") {
let end = remain let end = remain
.find(|v: char| v.is_whitespace() || matches!(v, '<' | '_' | '?' | '$' | '"' | '\'')) .find(|v: char| v.is_whitespace() || matches!(v, '<' | '_' | '?' | '$' | '"' | '\''))
.unwrap_or_else(|| remain.len()); .unwrap_or(remain.len());
let (value, remain) = remain.split_at(end); let (value, remain) = remain.split_at(end);
let term = BlankNode::new(value).map_err(|error| TermParseError { let term = BlankNode::new(value).map_err(|error| TermParseError {
kind: TermParseErrorKind::BlankNode { kind: TermParseErrorKind::BlankNode {
@ -188,7 +188,7 @@ fn read_literal(s: &str) -> Result<(Literal, &str), TermParseError> {
return if let Some(remain) = remain.strip_prefix('@') { return if let Some(remain) = remain.strip_prefix('@') {
let end = remain let end = remain
.find(|v| !matches!(v, 'a'..='z' | 'A'..='Z' | '-')) .find(|v| !matches!(v, 'a'..='z' | 'A'..='Z' | '-'))
.unwrap_or_else(|| remain.len()); .unwrap_or(remain.len());
let (language, remain) = remain.split_at(end); let (language, remain) = remain.split_at(end);
Ok(( Ok((
Literal::new_language_tagged_literal(value, language).map_err( Literal::new_language_tagged_literal(value, language).map_err(

@ -1205,8 +1205,8 @@ parser! {
//[41] //[41]
rule Modify() -> Vec<GraphUpdateOperation> = with:Modify_with()? _ Modify_clear() c:Modify_clauses() _ u:(UsingClause() ** (_)) _ i("WHERE") _ pattern:GroupGraphPattern() { rule Modify() -> Vec<GraphUpdateOperation> = with:Modify_with()? _ Modify_clear() c:Modify_clauses() _ u:(UsingClause() ** (_)) _ i("WHERE") _ pattern:GroupGraphPattern() {
let (delete, insert) = c; let (delete, insert) = c;
let mut delete = delete.unwrap_or_else(Vec::new); let mut delete = delete.unwrap_or_default();
let mut insert = insert.unwrap_or_else(Vec::new); let mut insert = insert.unwrap_or_default();
let mut pattern = pattern; let mut pattern = pattern;
let mut using = if u.is_empty() { let mut using = if u.is_empty() {
@ -1325,7 +1325,7 @@ parser! {
//[51] //[51]
rule QuadsNotTriples() -> Vec<QuadPattern> = i("GRAPH") _ g:VarOrIri() _ "{" _ t:TriplesTemplate()? _ "}" { rule QuadsNotTriples() -> Vec<QuadPattern> = i("GRAPH") _ g:VarOrIri() _ "{" _ t:TriplesTemplate()? _ "}" {
t.unwrap_or_else(Vec::new).into_iter().map(|t| QuadPattern::new(t.subject, t.predicate, t.object, g.clone())).collect() t.unwrap_or_default().into_iter().map(|t| QuadPattern::new(t.subject, t.predicate, t.object, g.clone())).collect()
} }
//[52] //[52]

@ -119,6 +119,7 @@ pub struct QueryOptions {
impl QueryOptions { impl QueryOptions {
/// Use a given [`ServiceHandler`] to execute [SPARQL 1.1 Federated Query](https://www.w3.org/TR/sparql11-federated-query/) SERVICE calls. /// Use a given [`ServiceHandler`] to execute [SPARQL 1.1 Federated Query](https://www.w3.org/TR/sparql11-federated-query/) SERVICE calls.
#[inline] #[inline]
#[must_use]
pub fn with_service_handler(mut self, service_handler: impl ServiceHandler + 'static) -> Self { pub fn with_service_handler(mut self, service_handler: impl ServiceHandler + 'static) -> Self {
self.service_handler = Some(Rc::new(ErrorConversionServiceHandler::wrap( self.service_handler = Some(Rc::new(ErrorConversionServiceHandler::wrap(
service_handler, service_handler,
@ -128,6 +129,7 @@ impl QueryOptions {
/// Disables the `SERVICE` calls /// Disables the `SERVICE` calls
#[inline] #[inline]
#[must_use]
pub fn without_service_handler(mut self) -> Self { pub fn without_service_handler(mut self) -> Self {
self.service_handler = Some(Rc::new(EmptyServiceHandler)); self.service_handler = Some(Rc::new(EmptyServiceHandler));
self self
@ -135,6 +137,7 @@ impl QueryOptions {
/// Sets a timeout for HTTP requests done during SPARQL evaluation /// Sets a timeout for HTTP requests done during SPARQL evaluation
#[cfg(feature = "http_client")] #[cfg(feature = "http_client")]
#[must_use]
pub fn with_http_timeout(mut self, timeout: Duration) -> Self { pub fn with_http_timeout(mut self, timeout: Duration) -> Self {
self.http_timeout = Some(timeout); self.http_timeout = Some(timeout);
self self
@ -162,6 +165,7 @@ impl QueryOptions {
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[inline] #[inline]
#[must_use]
pub fn with_custom_function( pub fn with_custom_function(
mut self, mut self,
name: NamedNode, name: NamedNode,

@ -80,7 +80,9 @@ pub struct ColumnFamilyDefinition {
#[derive(Clone)] #[derive(Clone)]
pub struct Db(Arc<DbHandler>); pub struct Db(Arc<DbHandler>);
#[allow(clippy::non_send_fields_in_send_ty)]
unsafe impl Send for Db {} unsafe impl Send for Db {}
unsafe impl Sync for Db {} unsafe impl Sync for Db {}
struct DbHandler { struct DbHandler {
@ -926,7 +928,9 @@ impl Drop for Iter {
} }
} }
#[allow(clippy::non_send_fields_in_send_ty)]
unsafe impl Send for Iter {} unsafe impl Send for Iter {}
unsafe impl Sync for Iter {} unsafe impl Sync for Iter {}
impl Iter { impl Iter {

@ -77,7 +77,7 @@ pub fn main() -> std::io::Result<()> {
let file = file.to_string(); let file = file.to_string();
spawn(move || { spawn(move || {
let format = file let format = file
.rsplit_once(".") .rsplit_once('.')
.and_then(|(_, extension)| { .and_then(|(_, extension)| {
DatasetFormat::from_extension(extension) DatasetFormat::from_extension(extension)
.or_else(|| GraphFormat::from_extension(extension)?.try_into().ok()) .or_else(|| GraphFormat::from_extension(extension)?.try_into().ok())

@ -79,7 +79,7 @@ pub fn load_to_store<'a>(
pub fn load_to_graph(url: &str, graph: &mut Graph) -> Result<()> { pub fn load_to_graph(url: &str, graph: &mut Graph) -> Result<()> {
let format = url let format = url
.rsplit_once(".") .rsplit_once('.')
.and_then(|(_, extension)| GraphFormat::from_extension(extension)) .and_then(|(_, extension)| GraphFormat::from_extension(extension))
.ok_or_else(|| anyhow!("Serialization type not found for {}", url))?; .ok_or_else(|| anyhow!("Serialization type not found for {}", url))?;
let parser = GraphParser::from_format(format).with_base_iri(url)?; let parser = GraphParser::from_format(format).with_base_iri(url)?;
@ -101,7 +101,7 @@ pub fn load_to_dataset<'a>(
to_graph_name: impl Into<GraphNameRef<'a>>, to_graph_name: impl Into<GraphNameRef<'a>>,
) -> Result<()> { ) -> Result<()> {
let to_graph_name = to_graph_name.into(); let to_graph_name = to_graph_name.into();
let extension = url.rsplit_once(".").map(|(_, ext)| ext); let extension = url.rsplit_once('.').map(|(_, ext)| ext);
if let Some(format) = extension.and_then(GraphFormat::from_extension) { if let Some(format) = extension.and_then(GraphFormat::from_extension) {
let parser = GraphParser::from_format(format).with_base_iri(url)?; let parser = GraphParser::from_format(format).with_base_iri(url)?;
for t in parser.read_triples(read_file(url)?)? { for t in parser.read_triples(read_file(url)?)? {

Loading…
Cancel
Save