Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Apr 2, 2024
1 parent 3a15db7 commit 39321ed
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 13 deletions.
3 changes: 1 addition & 2 deletions components/salsa-2022-macros/src/salsa_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ impl<A: AllowedOptions> SalsaStruct<A> {
// `::salsa::debug::helper::SalsaDebug` will use `DebugWithDb` or fallbak to `Debug`
let fields = self
.all_fields()
.into_iter()
.map(|field| -> TokenStream {
let field_name_string = field.name().to_string();
let field_getter = field.get_name();
Expand Down Expand Up @@ -338,7 +337,7 @@ impl SalsaField {
if BANNED_FIELD_NAMES.iter().any(|n| *n == field_name_str) {
return Err(syn::Error::new(
field_name.span(),
&format!(
format!(
"the field name `{}` is disallowed in salsa structs",
field_name_str
),
Expand Down
1 change: 1 addition & 0 deletions components/salsa-2022-macros/src/tracked_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ pub(crate) fn tracked_impl(
),
None => format!("{}", self_type_name),
};
#[allow(clippy::manual_try_fold)] // we accumulate errors
let extra_impls = item_impl
.items
.iter_mut()
Expand Down
1 change: 1 addition & 0 deletions components/salsa-2022-macros/src/tracked_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ impl TrackedStruct {
type Fields = ( #(#field_tys,)* );
type Revisions = [salsa::Revision; #arity];

#[allow(clippy::unused_unit)]
fn id_fields(fields: &Self::Fields) -> impl std::hash::Hash {
( #( &fields.#id_field_indices ),* )
}
Expand Down
6 changes: 1 addition & 5 deletions components/salsa-2022/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,7 @@ pub mod helper {
use std::{fmt, marker::PhantomData};

pub trait Fallback<T: fmt::Debug, Db: ?Sized> {
fn salsa_debug<'a, 'b>(
a: &'a T,
_db: &'b Db,
_include_all_fields: bool,
) -> &'a dyn fmt::Debug {
fn salsa_debug<'a>(a: &'a T, _db: &Db, _include_all_fields: bool) -> &'a dyn fmt::Debug {
a
}
}
Expand Down
6 changes: 2 additions & 4 deletions components/salsa-2022/src/hash.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::hash::{BuildHasher, Hash, Hasher};
use std::hash::{BuildHasher, Hash};

pub(crate) type FxHasher = std::hash::BuildHasherDefault<rustc_hash::FxHasher>;
pub(crate) type FxIndexSet<K> = indexmap::IndexSet<K, FxHasher>;
Expand All @@ -8,7 +8,5 @@ pub(crate) type FxLinkedHashSet<K> = hashlink::LinkedHashSet<K, FxHasher>;
pub(crate) type FxHashSet<K> = std::collections::HashSet<K, FxHasher>;

pub(crate) fn hash<T: Hash>(t: &T) -> u64 {
let mut hasher = FxHasher::default().build_hasher();
t.hash(&mut hasher);
hasher.finish()
FxHasher::default().hash_one(t)
}
3 changes: 2 additions & 1 deletion components/salsa-2022/src/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::storage::HasJars;

/// Initializes the `DB`'s jars in-place
///
/// # Safety:
/// # Safety
///
/// `init` must fully initialize all of jars fields
pub unsafe fn create_jars_inplace<DB: HasJars>(init: impl FnOnce(*mut DB::Jars)) -> Box<DB::Jars> {
Expand All @@ -31,6 +31,7 @@ pub unsafe fn create_jars_inplace<DB: HasJars>(init: impl FnOnce(*mut DB::Jars))
//
// Safe if you know that data at `u` will remain shared
// until the reference `t` expires.
#[allow(clippy::needless_lifetimes)]
pub(crate) unsafe fn transmute_lifetime<'t, 'u, T, U>(_t: &'t T, u: &'u U) -> &'t U {
std::mem::transmute(u)
}
1 change: 0 additions & 1 deletion components/salsa-2022/src/tracked_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use crate::{
ingredient_list::IngredientList,
interned::{InternedId, InternedIngredient},
key::{DatabaseKeyIndex, DependencyIndex},
plumbing::transmute_lifetime,
runtime::{local_state::QueryOrigin, Runtime},
salsa_struct::SalsaStructInDb,
Database, Durability, Event, IngredientIndex, Revision,
Expand Down

0 comments on commit 39321ed

Please sign in to comment.