Lints against 1.74

pull/705/head
Tpt 11 months ago committed by Thomas Tanon
parent 4b3f3f3278
commit 2a135283d5
  1. 12
      .cargo/config.toml
  2. 16
      .github/workflows/tests.yml
  3. 2
      lib/oxsdatatypes/src/double.rs
  4. 2
      lib/oxsdatatypes/src/float.rs
  5. 2
      lib/oxttl/src/line_formats.rs
  6. 2
      lib/spargebra/src/algebra.rs
  7. 17
      lib/spargebra/src/parser.rs
  8. 2
      lib/src/sparql/eval.rs
  9. 2
      lib/src/sparql/mod.rs
  10. 12
      lints/build_config.py

@ -29,6 +29,7 @@ rustflags = [
"-Wclippy::empty-enum",
"-Wclippy::empty-structs-with-brackets",
"-Wclippy::enum-glob-use",
"-Wclippy::error-impl-error",
"-Wclippy::exit",
"-Wclippy::expect-used",
"-Wclippy::expl-impl-clone-on-copy",
@ -43,8 +44,10 @@ rustflags = [
"-Wclippy::format-push-string",
"-Wclippy::from-iter-instead-of-collect",
"-Wclippy::get-unwrap",
"-Wclippy::host-endian-bytes",
"-Wclippy::if-not-else",
"-Wclippy::if-then-some-else-none",
"-Wclippy::ignored-unit-patterns",
"-Wclippy::implicit-clone",
"-Wclippy::implicit-hasher",
"-Wclippy::inconsistent-struct-constructor",
@ -82,7 +85,9 @@ rustflags = [
"-Wclippy::mem-forget",
"-Wclippy::mismatching-type-param-order",
"-Wclippy::missing-assert-message",
"-Wclippy::missing-asserts-for-indexing",
"-Wclippy::missing-enforced-import-renames",
"-Wclippy::missing-fields-in-debug",
"-Wclippy::multiple-inherent-impl",
"-Wclippy::mut-mut",
"-Wclippy::mutex-atomic",
@ -91,6 +96,7 @@ rustflags = [
"-Wclippy::needless-continue",
"-Wclippy::needless-for-each",
"-Wclippy::needless-pass-by-value",
"-Wclippy::needless-raw-strings",
"-Wclippy::negative-feature-names",
"-Wclippy::no-effect-underscore-binding",
"-Wclippy::no-mangle-with-rust-abi",
@ -101,6 +107,8 @@ rustflags = [
"-Wclippy::print-stderr",
"-Wclippy::print-stdout",
"-Wclippy::ptr-as-ptr",
"-Wclippy::ptr-cast-constness",
"-Wclippy::pub-without-shorthand",
"-Wclippy::range-minus-one",
"-Wclippy::range-plus-one",
"-Wclippy::rc-buffer",
@ -108,19 +116,23 @@ rustflags = [
"-Wclippy::redundant-closure-for-method-calls",
"-Wclippy::redundant-else",
"-Wclippy::redundant-feature-names",
"-Wclippy::redundant-type-annotations",
"-Wclippy::ref-binding-to-reference",
"-Wclippy::ref-option-ref",
"-Wclippy::ref-patterns",
"-Wclippy::rest-pat-in-fully-bound-structs",
"-Wclippy::return-self-not-must-use",
"-Wclippy::same-functions-in-if-condition",
"-Wclippy::same-name-method",
"-Wclippy::semicolon-inside-block",
"-Wclippy::shadow-same",
"-Wclippy::should-panic-without-expect",
"-Wclippy::single-match-else",
"-Wclippy::stable-sort-primitive",
"-Wclippy::str-to-string",
"-Wclippy::string-add",
"-Wclippy::string-add-assign",
"-Wclippy::string-lit-chars-any",
"-Wclippy::string-to-string",
"-Wclippy::struct-excessive-bools",
"-Wclippy::suspicious-xor-used-as-pow",

@ -26,7 +26,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup default 1.70.0 && rustup component add clippy
- run: rustup update && rustup default 1.74.1 && rustup component add clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --all-targets -- -D warnings -D clippy::all
working-directory: ./lib/oxsdatatypes
@ -59,7 +59,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup default 1.70.0 && rustup target add wasm32-unknown-unknown && rustup component add clippy
- run: rustup update && rustup default 1.74.1 && rustup target add wasm32-unknown-unknown && rustup component add clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --lib --tests --target wasm32-unknown-unknown -- -D warnings -D clippy::all
working-directory: ./js
@ -70,7 +70,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup default 1.70.0 && rustup target add wasm32-wasi && rustup component add clippy
- run: rustup update && rustup default 1.74.1 && rustup target add wasm32-wasi && rustup component add clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --lib --tests --target wasm32-wasi -- -D warnings -D clippy::all
working-directory: ./lib
@ -81,7 +81,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup default 1.70.0 && rustup target add wasm32-unknown-unknown && rustup component add clippy
- run: rustup update && rustup default 1.74.1 && rustup target add wasm32-unknown-unknown && rustup component add clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --lib --tests --target wasm32-unknown-unknown --features getrandom/custom --features oxsdatatypes/custom-now -- -D warnings -D clippy::all
working-directory: ./lib
@ -123,7 +123,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup toolchain install nightly && rustup default 1.70.0
- run: rustup update && rustup toolchain install nightly && rustup default 1.74.1
- uses: Swatinem/rust-cache@v2
- run: rm Cargo.lock && cargo +nightly update -Z direct-minimal-versions
- run: cargo test
@ -200,7 +200,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup default 1.70.0
- run: rustup update && rustup default 1.74.1
- uses: Swatinem/rust-cache@v2
- run: cargo doc
working-directory: ./lib
@ -264,7 +264,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup toolchain install nightly && rustup default 1.70.0
- run: rustup update && rustup toolchain install nightly && rustup default 1.74.1
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-python@v4
with:
@ -285,7 +285,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup toolchain install nightly && rustup default 1.70.0
- run: rustup update && rustup toolchain install nightly && rustup default 1.74.1
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-python@v4
with:

@ -75,7 +75,7 @@ impl Double {
#[inline]
#[must_use]
pub fn is_identical_with(self, other: Self) -> bool {
self.value.to_ne_bytes() == other.value.to_ne_bytes()
self.value.to_bits() == other.value.to_bits()
}
pub const MIN: Self = Self { value: f64::MIN };

@ -75,7 +75,7 @@ impl Float {
#[inline]
#[must_use]
pub fn is_identical_with(self, other: Self) -> bool {
self.value.to_ne_bytes() == other.value.to_ne_bytes()
self.value.to_bits() == other.value.to_bits()
}
pub const MIN: Self = Self { value: f32::MIN };

@ -246,7 +246,7 @@ impl RuleRecognizer for NQuadsRecognizer {
self.emit_quad(results, GraphName::DefaultGraph);
errors.push("Triples should be followed by a dot".into())
}
[NQuadsState::ExpectLiteralAnnotationOrGraphNameOrDot { ref value }] => {
[NQuadsState::ExpectLiteralAnnotationOrGraphNameOrDot { value }] => {
self.objects.push(Literal::new_simple_literal(value).into());
self.emit_quad(results, GraphName::DefaultGraph);
errors.push("Triples should be followed by a dot".into())

@ -969,7 +969,7 @@ impl GraphPattern {
right.lookup_in_scope_variables(callback);
}
Self::Graph { name, inner } => {
if let NamedNodePattern::Variable(ref g) = name {
if let NamedNodePattern::Variable(g) = &name {
callback(g);
}
inner.lookup_in_scope_variables(callback);

@ -1,3 +1,4 @@
#![allow(clippy::ignored_unit_patterns)]
use crate::algebra::*;
use crate::query::*;
use crate::term::*;
@ -87,9 +88,9 @@ impl fmt::Display for ParseError {
impl Error for ParseError {
#[inline]
fn source(&self) -> Option<&(dyn Error + 'static)> {
match self.inner {
ParseErrorKind::InvalidBaseIri(ref e) => Some(e),
ParseErrorKind::Parser(ref e) => Some(e),
match &self.inner {
ParseErrorKind::InvalidBaseIri(e) => Some(e),
ParseErrorKind::Parser(e) => Some(e),
}
}
}
@ -1072,7 +1073,7 @@ parser! {
GraphNamePattern::Variable(graph_name) => GraphPattern::Graph { name: graph_name.clone().into(), inner: Box::new(bgp) },
}
}).reduce(new_join).unwrap_or_default();
let delete = d.into_iter().map(GroundQuadPattern::try_from).collect::<Result<Vec<_>,_>>().map_err(|_| "Blank nodes are not allowed in DELETE WHERE")?;
let delete = d.into_iter().map(GroundQuadPattern::try_from).collect::<Result<Vec<_>,_>>().map_err(|()| "Blank nodes are not allowed in DELETE WHERE")?;
Ok(vec![GraphUpdateOperation::DeleteInsert {
delete,
insert: Vec::new(),
@ -1150,7 +1151,7 @@ parser! {
}
rule DeleteClause() -> Vec<GroundQuadPattern> = i("DELETE") _ q:QuadPattern() {?
q.into_iter().map(GroundQuadPattern::try_from).collect::<Result<Vec<_>,_>>().map_err(|_| "Blank nodes are not allowed in DELETE WHERE")
q.into_iter().map(GroundQuadPattern::try_from).collect::<Result<Vec<_>,_>>().map_err(|()| "Blank nodes are not allowed in DELETE WHERE")
}
rule InsertClause() -> Vec<QuadPattern> = i("INSERT") _ q:QuadPattern() { q }
@ -1179,10 +1180,10 @@ parser! {
rule QuadPattern() -> Vec<QuadPattern> = "{" _ q:Quads() _ "}" { q }
rule QuadData() -> Vec<Quad> = "{" _ q:Quads() _ "}" {?
q.into_iter().map(Quad::try_from).collect::<Result<Vec<_>, ()>>().map_err(|_| "Variables are not allowed in INSERT DATA")
q.into_iter().map(Quad::try_from).collect::<Result<Vec<_>, ()>>().map_err(|()| "Variables are not allowed in INSERT DATA")
}
rule GroundQuadData() -> Vec<GroundQuad> = "{" _ q:Quads() _ "}" {?
q.into_iter().map(|q| GroundQuad::try_from(Quad::try_from(q)?)).collect::<Result<Vec<_>, ()>>().map_err(|_| "Variables and blank nodes are not allowed in DELETE DATA")
q.into_iter().map(|q| GroundQuad::try_from(Quad::try_from(q)?)).collect::<Result<Vec<_>, ()>>().map_err(|()| "Variables and blank nodes are not allowed in DELETE DATA")
}
rule Quads() -> Vec<QuadPattern> = q:(Quads_TriplesTemplate() / Quads_QuadsNotTriples()) ** (_) {
@ -1703,7 +1704,7 @@ parser! {
rule QuotedTripleData() -> GroundTriple = "<<" _ s:DataValueTerm() _ p:QuotedTripleData_p() _ o:DataValueTerm() _ ">>" {?
Ok(GroundTriple {
subject: s.try_into().map_err(|_| "Literals are not allowed in subject position of nested patterns")?,
subject: s.try_into().map_err(|()| "Literals are not allowed in subject position of nested patterns")?,
predicate: p,
object: o
})

@ -5508,7 +5508,7 @@ fn slice_key<T: Eq>(slice: &[T], element: &T) -> Option<usize> {
}
fn generate_uuid(buffer: &mut String) {
let mut uuid = random::<u128>().to_ne_bytes();
let mut uuid = random::<u128>().to_le_bytes();
uuid[6] = (uuid[6] & 0x0F) | 0x40;
uuid[8] = (uuid[8] & 0x3F) | 0x80;

@ -320,6 +320,6 @@ impl fmt::Debug for QueryExplanation {
);
}
obj.field("tree", &self.inner);
obj.finish()
obj.finish_non_exhaustive()
}
}

@ -1,7 +1,8 @@
import json
from pathlib import Path
from urllib.request import urlopen
MSRV = "1.70.0"
MSRV = "1.74.0"
DEFAULT_BUILD_FLAGS = {
"-Wtrivial-casts",
"-Wtrivial-numeric-casts",
@ -10,9 +11,11 @@ DEFAULT_BUILD_FLAGS = {
"-Wunused-qualifications",
}
FLAGS_BLACKLIST = {
"-Wclippy::absolute-paths", # TODO: might be nice
"-Wclippy::alloc-instead-of-core",
"-Wclippy::arithmetic-side-effects", # TODO: might be nice
"-Wclippy::as-conversions",
"-Wclippy::big-endian-bytes",
"-Wclippy::cargo-common-metadata", # TODO: might be nice
"-Wclippy::doc-markdown", # Too many false positives
"-Wclippy::default-numeric-fallback",
@ -25,9 +28,10 @@ FLAGS_BLACKLIST = {
"-Wclippy::impl-trait-in-params",
"-Wclippy::implicit-return",
"-Wclippy::indexing-slicing",
"-Wclippy::integer-arithmetic",
"-Wclippy::integer-division",
"-Wclippy::little-endian-bytes",
"-Wclippy::map-err-ignore",
"-Wclippy::min-ident-chars",
"-Wclippy::missing-docs-in-private-items",
"-Wclippy::missing-errors-doc",
"-Wclippy::missing-inline-in-public-items",
@ -43,11 +47,13 @@ FLAGS_BLACKLIST = {
"-Wclippy::option-option",
"-Wclippy::pattern-type-mismatch",
"-Wclippy::pub-use",
"-Wclippy::pub-with-shorthand",
"-Wclippy::question-mark-used",
"-Wclippy::self-named-module-files", # TODO: might be nice
"-Wclippy::semicolon-if-nothing-returned", # TODO: might be nice
"-Wclippy::semicolon-outside-block",
"-Wclippy::similar-names",
"-Wclippy::single-call-fn",
"-Wclippy::single-char-lifetime-names",
"-Wclippy::std-instead-of-alloc",
"-Wclippy::std-instead-of-core",
@ -76,7 +82,7 @@ for flag in FLAGS_BLACKLIST:
else:
print(f"Unused blacklisted flag: {flag}")
with open("./config.toml", "wt") as fp:
with (Path(__file__).parent.parent / ".cargo" / "config.toml").open("wt") as fp:
fp.write("[build]\n")
fp.write("rustflags = [\n")
for flag in sorted(build_flags):
Loading…
Cancel
Save