Skip to content

Commit 4ddf51a

Browse files
committed
clippy and hanging_detection fixes
1 parent 0d4e9fa commit 4ddf51a

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,12 +2490,10 @@ impl AggregationUpdateQueue {
24902490
TaskDataCategory::Meta
24912491
},
24922492
);
2493-
if let Some(task_type) = task_type {
2494-
if !task.has_key(&CachedDataItemKey::TaskType {}) {
2495-
let _ = task.add_new(CachedDataItem::TaskType {
2496-
value: Arc::from(task_type),
2497-
});
2498-
}
2493+
if let Some(task_type) = task_type
2494+
&& !task.has_key(&CachedDataItemKey::TaskType {})
2495+
{
2496+
task.add_new(CachedDataItem::TaskType { value: task_type });
24992497
}
25002498
let state = get_mut_or_insert_with!(task, Activeness, || ActivenessState::new(task_id));
25012499
let is_new = state.is_empty();

turbopack/crates/turbo-tasks-backend/src/utils/dash_map_raw_entry.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::{
2-
hash::{BuildHasher, Hash, Hasher},
2+
hash::{BuildHasher, Hash},
33
ops::{Deref, DerefMut},
44
};
55

@@ -17,11 +17,7 @@ pub fn raw_entry<'l, K: Eq + Hash + AsRef<Q>, V, Q: Eq + Hash, S: BuildHasher +
1717
let result = shard.find_or_find_insert_slot(
1818
hash,
1919
|(k, _v)| k.as_ref() == key,
20-
|(k, _v)| {
21-
let mut hasher = hasher.build_hasher();
22-
k.hash(&mut hasher);
23-
hasher.finish()
24-
},
20+
|(k, _v)| hasher.hash_one(k),
2521
);
2622
match result {
2723
Ok(bucket) => RawEntry::Occupied(OccupiedEntry { bucket, shard }),

turbopack/crates/turbo-tasks/src/event.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use tokio::time::{Timeout, timeout};
1616

1717
pub trait EventDescriptor {
1818
#[cfg(feature = "hanging_detection")]
19-
fn get_description(&self) -> Arc<dyn Fn() -> String + Sync + Send>;
19+
fn get_description(self) -> Arc<dyn Fn() -> String + Sync + Send>;
2020
}
2121

2222
impl<T, InnerFn> EventDescriptor for T
@@ -25,8 +25,8 @@ where
2525
InnerFn: Fn() -> String + Sync + Send + 'static,
2626
{
2727
#[cfg(feature = "hanging_detection")]
28-
fn get_description(&self) -> Arc<dyn Fn() -> String + Sync + Send> {
29-
(self)()
28+
fn get_description(self) -> Arc<dyn Fn() -> String + Sync + Send> {
29+
Arc::new((self)())
3030
}
3131
}
3232

@@ -38,14 +38,14 @@ pub struct EventDescription {
3838

3939
impl EventDescription {
4040
#[inline(always)]
41-
pub fn new<InnerFn>(_description: impl FnOnce() -> InnerFn) -> Self
41+
pub fn new<InnerFn>(#[allow(unused_variables)] description: impl FnOnce() -> InnerFn) -> Self
4242
where
4343
InnerFn: Fn() -> String + Sync + Send + 'static,
4444
{
45-
return Self {
45+
Self {
4646
#[cfg(feature = "hanging_detection")]
4747
description: Arc::new((description)()),
48-
};
48+
}
4949
}
5050
}
5151

@@ -61,8 +61,8 @@ impl Display for EventDescription {
6161

6262
impl EventDescriptor for EventDescription {
6363
#[cfg(feature = "hanging_detection")]
64-
fn get_description(&self) -> Arc<dyn Fn() -> String + Sync + Send> {
65-
self.description.clone()
64+
fn get_description(self) -> Arc<dyn Fn() -> String + Sync + Send> {
65+
self.description
6666
}
6767
}
6868

@@ -87,14 +87,14 @@ impl Event {
8787
/// The outer closure allows avoiding extra lookups (e.g. task type info) that may be needed to
8888
/// capture information needed for constructing (moving into) the inner closure.
8989
#[inline(always)]
90-
pub fn new(_description: impl EventDescriptor) -> Self {
90+
pub fn new(#[allow(unused_variables)] description: impl EventDescriptor) -> Self {
9191
#[cfg(not(feature = "hanging_detection"))]
9292
return Self {
9393
event: event_listener::Event::new(),
9494
};
9595
#[cfg(feature = "hanging_detection")]
9696
return Self {
97-
description: _description.get_description(),
97+
description: description.get_description(),
9898
event: event_listener::Event::new(),
9999
};
100100
}

0 commit comments

Comments
 (0)