diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 723f8b68d..07b8bbc10 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -51,7 +51,7 @@ jobs: - name: Format run: cargo fmt -- --check - name: Clippy - run: cargo clippy --workspace --all-features --all-targets + run: cargo clippy --workspace --all-features --all-targets -- -D warnings - name: Test run: cargo test --workspace --all-features --all-targets - name: Test docs diff --git a/src/local_state.rs b/src/local_state.rs index 03473928b..0e92e5812 100644 --- a/src/local_state.rs +++ b/src/local_state.rs @@ -37,13 +37,11 @@ where /// Databases are attached with `attach_database`. pub fn with_attached_database(op: impl FnOnce(&dyn Database) -> R) -> Option { LOCAL_STATE.with(|state| { - if let Some(db) = state.database.get() { + state.database.get().map(|db| { // SAFETY: We always attach the database in for the entire duration of a function, // so it cannot become "unattached" while this function is running. - Some(op(unsafe { db.as_ref() })) - } else { - None - } + op(unsafe { db.as_ref() }) + }) }) } diff --git a/src/tracked_struct/struct_map.rs b/src/tracked_struct/struct_map.rs index 4779a2783..b6036a8a1 100644 --- a/src/tracked_struct/struct_map.rs +++ b/src/tracked_struct/struct_map.rs @@ -80,7 +80,7 @@ where /// /// * If value with same `value.id` is already present in the map. /// * If value not created in current revision. - pub fn insert<'db>(&'db self, current_revision: Revision, value: Value) -> C::Struct<'db> { + pub fn insert(&self, current_revision: Revision, value: Value) -> C::Struct<'_> { assert_eq!(value.created_at, current_revision); let id = value.id; @@ -119,7 +119,7 @@ where /// /// * If the value is not present in the map. /// * If the value is already updated in this revision. - pub fn update<'db>(&'db self, current_revision: Revision, id: Id) -> Update<'db, C> { + pub fn update(&self, current_revision: Revision, id: Id) -> Update<'_, C> { let mut data = self.map.get_mut(&id).unwrap(); // UNSAFE: We never permit `&`-access in the current revision until data.created_at @@ -164,7 +164,7 @@ where /// /// * If the value is not present in the map. /// * If the value has not been updated in this revision. - pub fn get<'db>(&'db self, current_revision: Revision, id: Id) -> C::Struct<'db> { + pub fn get(&self, current_revision: Revision, id: Id) -> C::Struct<'_> { Self::get_from_map(&self.map, current_revision, id) } @@ -174,11 +174,11 @@ where /// /// * If the value is not present in the map. /// * If the value has not been updated in this revision. - fn get_from_map<'db>( - map: &'db FxDashMap>>, + fn get_from_map( + map: &FxDashMap>>, current_revision: Revision, id: Id, - ) -> C::Struct<'db> { + ) -> C::Struct<'_> { let data = map.get(&id).unwrap(); // UNSAFE: We permit `&`-access in the current revision once data.created_at @@ -231,7 +231,7 @@ where /// /// * If the value is not present in the map. /// * If the value has not been updated in this revision. - pub fn get<'db>(&'db self, current_revision: Revision, id: Id) -> C::Struct<'db> { + pub fn get(&self, current_revision: Revision, id: Id) -> C::Struct<'_> { StructMap::get_from_map(&self.map, current_revision, id) } } diff --git a/tests/tracked_struct_db1_lt.rs b/tests/tracked_struct_db1_lt.rs index 6931ea7e3..43cffc1aa 100644 --- a/tests/tracked_struct_db1_lt.rs +++ b/tests/tracked_struct_db1_lt.rs @@ -20,6 +20,7 @@ struct MyTracked2<'db2> { field: u32, } +#[allow(dead_code)] #[salsa::db] #[derive(Default)] struct Database { diff --git a/tests/tracked_with_intern.rs b/tests/tracked_with_intern.rs index 508a93c1d..1f01fd6d4 100644 --- a/tests/tracked_with_intern.rs +++ b/tests/tracked_with_intern.rs @@ -3,6 +3,7 @@ use test_log::test; +#[allow(dead_code)] #[salsa::db] #[derive(Default)] struct Database {