Skip to content

Commit

Permalink
clippy warning-clean (and add -D warnings to CI)
Browse files Browse the repository at this point in the history
  • Loading branch information
carljm committed Aug 2, 2024
1 parent cd339fc commit 2117cec
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions src/local_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@ where
/// Databases are attached with `attach_database`.
pub fn with_attached_database<R>(op: impl FnOnce(&dyn Database) -> R) -> Option<R> {
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() })
})
})
}

Expand Down
14 changes: 7 additions & 7 deletions src/tracked_struct/struct_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>) -> C::Struct<'db> {
pub fn insert(&self, current_revision: Revision, value: Value<C>) -> C::Struct<'_> {
assert_eq!(value.created_at, current_revision);

let id = value.id;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand All @@ -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<Id, Alloc<Value<C>>>,
fn get_from_map(
map: &FxDashMap<Id, Alloc<Value<C>>>,
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
Expand Down Expand Up @@ -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)
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/tracked_struct_db1_lt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct MyTracked2<'db2> {
field: u32,
}

#[allow(dead_code)]
#[salsa::db]
#[derive(Default)]
struct Database {
Expand Down
1 change: 1 addition & 0 deletions tests/tracked_with_intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use test_log::test;

#[allow(dead_code)]
#[salsa::db]
#[derive(Default)]
struct Database {
Expand Down

0 comments on commit 2117cec

Please sign in to comment.