Lints against 1.74

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

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

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

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

@ -246,7 +246,7 @@ impl RuleRecognizer for NQuadsRecognizer {
self.emit_quad(results, GraphName::DefaultGraph); self.emit_quad(results, GraphName::DefaultGraph);
errors.push("Triples should be followed by a dot".into()) 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.objects.push(Literal::new_simple_literal(value).into());
self.emit_quad(results, GraphName::DefaultGraph); self.emit_quad(results, GraphName::DefaultGraph);
errors.push("Triples should be followed by a dot".into()) errors.push("Triples should be followed by a dot".into())

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

@ -1,3 +1,4 @@
#![allow(clippy::ignored_unit_patterns)]
use crate::algebra::*; use crate::algebra::*;
use crate::query::*; use crate::query::*;
use crate::term::*; use crate::term::*;
@ -87,9 +88,9 @@ impl fmt::Display for ParseError {
impl Error for ParseError { impl Error for ParseError {
#[inline] #[inline]
fn source(&self) -> Option<&(dyn Error + 'static)> { fn source(&self) -> Option<&(dyn Error + 'static)> {
match self.inner { match &self.inner {
ParseErrorKind::InvalidBaseIri(ref e) => Some(e), ParseErrorKind::InvalidBaseIri(e) => Some(e),
ParseErrorKind::Parser(ref 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) }, GraphNamePattern::Variable(graph_name) => GraphPattern::Graph { name: graph_name.clone().into(), inner: Box::new(bgp) },
} }
}).reduce(new_join).unwrap_or_default(); }).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 { Ok(vec![GraphUpdateOperation::DeleteInsert {
delete, delete,
insert: Vec::new(), insert: Vec::new(),
@ -1150,7 +1151,7 @@ parser! {
} }
rule DeleteClause() -> Vec<GroundQuadPattern> = i("DELETE") _ q:QuadPattern() {? 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 } rule InsertClause() -> Vec<QuadPattern> = i("INSERT") _ q:QuadPattern() { q }
@ -1179,10 +1180,10 @@ parser! {
rule QuadPattern() -> Vec<QuadPattern> = "{" _ q:Quads() _ "}" { q } rule QuadPattern() -> Vec<QuadPattern> = "{" _ q:Quads() _ "}" { q }
rule QuadData() -> Vec<Quad> = "{" _ q:Quads() _ "}" {? 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() _ "}" {? 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()) ** (_) { rule Quads() -> Vec<QuadPattern> = q:(Quads_TriplesTemplate() / Quads_QuadsNotTriples()) ** (_) {
@ -1703,7 +1704,7 @@ parser! {
rule QuotedTripleData() -> GroundTriple = "<<" _ s:DataValueTerm() _ p:QuotedTripleData_p() _ o:DataValueTerm() _ ">>" {? rule QuotedTripleData() -> GroundTriple = "<<" _ s:DataValueTerm() _ p:QuotedTripleData_p() _ o:DataValueTerm() _ ">>" {?
Ok(GroundTriple { 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, predicate: p,
object: o object: o
}) })

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

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

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