From accadaac347bca4d3fdd44f5a859611a4ac342b5 Mon Sep 17 00:00:00 2001 From: Tpt Date: Sun, 25 Feb 2024 18:02:30 +0100 Subject: [PATCH] CI: Uses 1.76.0 for Clippy --- .github/workflows/tests.yml | 12 +++++----- Cargo.toml | 6 ++++- lib/oxigraph/src/storage/backend/rocksdb.rs | 26 ++++++++++----------- lib/oxigraph/src/store.rs | 24 +++++++++++++++++-- lib/oxrdf/src/parser.rs | 3 ++- lints/build_clippy_config.py | 3 ++- 6 files changed, 50 insertions(+), 24 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5b501b5f..9e392ac2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,7 +30,7 @@ jobs: submodules: true - uses: ./.github/actions/setup-rust with: - version: 1.74.1 + version: 1.76.0 component: clippy - run: cargo clippy --all-targets -- -D warnings -D clippy::all working-directory: ./lib/oxsdatatypes @@ -69,7 +69,7 @@ jobs: submodules: true - uses: ./.github/actions/setup-rust with: - version: 1.74.1 + version: 1.76.0 target: wasm32-unknown-unknown component: clippy - run: cargo clippy --lib --tests --target wasm32-unknown-unknown -- -D warnings -D clippy::all @@ -83,7 +83,7 @@ jobs: submodules: true - uses: ./.github/actions/setup-rust with: - version: 1.74.1 + version: 1.76.0 target: wasm32-wasi component: clippy - run: cargo clippy --lib --tests --target wasm32-wasi -- -D warnings -D clippy::all @@ -99,7 +99,7 @@ jobs: submodules: true - uses: ./.github/actions/setup-rust with: - version: 1.74.1 + version: 1.76.0 target: wasm32-unknown-emscripten component: clippy - run: cargo clippy --lib --tests --target wasm32-unknown-emscripten -- -D warnings -D clippy::all @@ -115,7 +115,7 @@ jobs: submodules: true - uses: ./.github/actions/setup-rust with: - version: 1.74.1 + version: 1.76.0 target: wasm32-unknown-unknown component: clippy - run: cargo clippy --lib --tests --target wasm32-unknown-unknown --features getrandom/custom --features oxsdatatypes/custom-now -- -D warnings -D clippy::all @@ -249,7 +249,7 @@ jobs: submodules: true - uses: ./.github/actions/setup-rust with: - version: 1.74.1 + version: 1.76.0 - run: cargo doc env: RUSTDOCFLAGS: -D warnings diff --git a/Cargo.toml b/Cargo.toml index 7e0fe900..f98afa72 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -149,12 +149,15 @@ implicit_hasher = "warn" inconsistent_struct_constructor = "warn" index_refutable_slice = "warn" inefficient_to_string = "warn" +infinite_loop = "warn" inline_always = "warn" inline_asm_x86_att_syntax = "warn" inline_asm_x86_intel_syntax = "warn" +into_iter_without_iter = "warn" invalid_upcast_comparisons = "warn" items_after_statements = "warn" iter_not_returning_iterator = "warn" +iter_without_into_iter = "warn" large_digit_groups = "warn" large_futures = "warn" large_include_file = "warn" @@ -182,7 +185,6 @@ mem_forget = "warn" mismatching_type_param_order = "warn" missing_assert_message = "warn" missing_asserts_for_indexing = "warn" -missing_enforced_import_renames = "warn" missing_fields_in_debug = "warn" multiple_inherent_impl = "warn" mut_mut = "warn" @@ -192,6 +194,7 @@ needless_bitwise_bool = "warn" needless_continue = "warn" needless_for_each = "warn" needless_pass_by_value = "warn" +needless_raw_string_hashes = "warn" needless_raw_strings = "warn" negative_feature_names = "warn" no_effect_underscore_binding = "warn" @@ -231,6 +234,7 @@ string_add_assign = "warn" string_lit_chars_any = "warn" string_to_string = "warn" struct_excessive_bools = "warn" +struct_field_names = "warn" suspicious_xor_used_as_pow = "warn" tests_outside_test_module = "warn" todo = "warn" diff --git a/lib/oxigraph/src/storage/backend/rocksdb.rs b/lib/oxigraph/src/storage/backend/rocksdb.rs index 6f5561f4..ac4f6dff 100644 --- a/lib/oxigraph/src/storage/backend/rocksdb.rs +++ b/lib/oxigraph/src/storage/backend/rocksdb.rs @@ -614,7 +614,7 @@ impl Db { (options, snapshot) }; let result = f(Transaction { - transaction: Rc::new(transaction), + inner: Rc::new(transaction), read_options, _lifetime: PhantomData, }); @@ -1033,7 +1033,7 @@ impl Reader { } let is_currently_valid = rocksdb_iter_valid(iter) != 0; Ok(Iter { - iter, + inner: iter, options, _upper_bound: upper_bound, _reader: self.clone(), @@ -1061,7 +1061,7 @@ impl Reader { } pub struct Transaction<'a> { - transaction: Rc<*mut rocksdb_transaction_t>, + inner: Rc<*mut rocksdb_transaction_t>, read_options: *mut rocksdb_readoptions_t, _lifetime: PhantomData<&'a ()>, } @@ -1069,7 +1069,7 @@ pub struct Transaction<'a> { impl Transaction<'_> { pub fn reader(&self) -> Reader { Reader { - inner: InnerReader::Transaction(Rc::downgrade(&self.transaction)), + inner: InnerReader::Transaction(Rc::downgrade(&self.inner)), options: unsafe { rocksdb_readoptions_create_copy(self.read_options) }, } } @@ -1081,7 +1081,7 @@ impl Transaction<'_> { ) -> Result, StorageError> { unsafe { let slice = ffi_result!(rocksdb_transaction_get_for_update_pinned_cf_with_status( - *self.transaction, + *self.inner, self.read_options, column_family.0, key.as_ptr().cast(), @@ -1111,7 +1111,7 @@ impl Transaction<'_> { ) -> Result<(), StorageError> { unsafe { ffi_result!(rocksdb_transaction_put_cf_with_status( - *self.transaction, + *self.inner, column_family.0, key.as_ptr().cast(), key.len(), @@ -1133,7 +1133,7 @@ impl Transaction<'_> { pub fn remove(&mut self, column_family: &ColumnFamily, key: &[u8]) -> Result<(), StorageError> { unsafe { ffi_result!(rocksdb_transaction_delete_cf_with_status( - *self.transaction, + *self.inner, column_family.0, key.as_ptr().cast(), key.len(), @@ -1223,7 +1223,7 @@ impl From for Vec { } pub struct Iter { - iter: *mut rocksdb_iterator_t, + inner: *mut rocksdb_iterator_t, is_currently_valid: bool, _upper_bound: Option>, _reader: Reader, // needed to ensure that DB still lives while iter is used @@ -1233,7 +1233,7 @@ pub struct Iter { impl Drop for Iter { fn drop(&mut self) { unsafe { - rocksdb_iter_destroy(self.iter); + rocksdb_iter_destroy(self.inner); rocksdb_readoptions_destroy(self.options); } } @@ -1251,15 +1251,15 @@ impl Iter { pub fn status(&self) -> Result<(), StorageError> { unsafe { - ffi_result!(rocksdb_iter_get_status(self.iter))?; + ffi_result!(rocksdb_iter_get_status(self.inner))?; } Ok(()) } pub fn next(&mut self) { unsafe { - rocksdb_iter_next(self.iter); - self.is_currently_valid = rocksdb_iter_valid(self.iter) != 0; + rocksdb_iter_next(self.inner); + self.is_currently_valid = rocksdb_iter_valid(self.inner) != 0; } } @@ -1267,7 +1267,7 @@ impl Iter { if self.is_valid() { unsafe { let mut len = 0; - let val = rocksdb_iter_key(self.iter, &mut len); + let val = rocksdb_iter_key(self.inner, &mut len); Some(slice::from_raw_parts(val.cast(), len)) } } else { diff --git a/lib/oxigraph/src/store.rs b/lib/oxigraph/src/store.rs index d84f5728..42e25dc3 100644 --- a/lib/oxigraph/src/store.rs +++ b/lib/oxigraph/src/store.rs @@ -688,7 +688,7 @@ impl Store { return Err(SerializerError::DatasetFormatExpected(serializer.format())); } let mut writer = serializer.serialize_to_write(write); - for quad in self.iter() { + for quad in self { writer.write_quad(&quad?)?; } Ok(writer.finish()?) @@ -1007,13 +1007,23 @@ impl Store { impl fmt::Display for Store { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - for t in self.iter() { + for t in self { writeln!(f, "{} .", t.map_err(|_| fmt::Error)?)?; } Ok(()) } } +impl IntoIterator for &Store { + type IntoIter = QuadIter; + type Item = Result; + + #[inline] + fn into_iter(self) -> Self::IntoIter { + self.iter() + } +} + /// An object to do operations during a transaction. /// /// See [`Store::transaction`] for a more detailed description. @@ -1514,6 +1524,16 @@ impl<'a> Transaction<'a> { } } +impl IntoIterator for &Transaction<'_> { + type IntoIter = QuadIter; + type Item = Result; + + #[inline] + fn into_iter(self) -> Self::IntoIter { + self.iter() + } +} + /// An iterator returning the quads contained in a [`Store`]. pub struct QuadIter { iter: ChainedDecodingQuadIterator, diff --git a/lib/oxrdf/src/parser.rs b/lib/oxrdf/src/parser.rs index 8986c352..447e1bcc 100644 --- a/lib/oxrdf/src/parser.rs +++ b/lib/oxrdf/src/parser.rs @@ -445,7 +445,8 @@ impl TermParseError { } } -#[cfg(all(test, feature = "rdf-star"))] +#[cfg(test)] +#[cfg(feature = "rdf-star")] mod tests { use super::*; diff --git a/lints/build_clippy_config.py b/lints/build_clippy_config.py index f56bcb00..476ed350 100644 --- a/lints/build_clippy_config.py +++ b/lints/build_clippy_config.py @@ -4,7 +4,7 @@ from urllib.request import urlopen import tomlkit -MSRV = "1.74.0" +MSRV = "1.76.0" LINT_BLACKLIST = { "absolute_paths", # TODO: might be nice "alloc_instead_of_core", @@ -24,6 +24,7 @@ LINT_BLACKLIST = { "implicit_return", "indexing_slicing", "integer_division", + "iter_over_hash_type", "little_endian_bytes", "map_err_ignore", "min_ident_chars",