Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some clippy issues, ignore others #6129

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ fn propagate_change_to_upper<C: AggregationContext>(
}
}

#[allow(clippy::disallowed_methods)] // Allow VecDeque::new() in this test
#[cfg(test)]
fn visit_graph<C: AggregationContext>(
aggregation_context: &C,
Expand All @@ -667,6 +668,7 @@ fn visit_graph<C: AggregationContext>(
(visited.len(), edges)
}

#[allow(clippy::disallowed_methods)] // Allow VecDeque::new() in this test
#[cfg(test)]
pub fn print_graph<C: AggregationContext>(
aggregation_context: &C,
Expand Down Expand Up @@ -696,7 +698,7 @@ pub fn print_graph<C: AggregationContext>(
while let Some(item) = queue.pop_front() {
let tree = bottom_tree(aggregation_context, &item, height);
let name = name_fn(&item);
let label = format!("{}", name);
let label = name.to_string();
let state = tree.state.read();
if color_upper {
print!(r#""{} {}" [color=red];"#, height - 1, name);
Expand Down
24 changes: 11 additions & 13 deletions crates/turbo-tasks-memory/src/aggregation_tree/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct NodeGuard {
}

impl NodeGuard {
unsafe fn new<'a>(guard: MutexGuard<'a, NodeInner>, node: Arc<Node>) -> Self {
unsafe fn new(guard: MutexGuard<'_, NodeInner>, node: Arc<Node>) -> Self {
NodeGuard {
guard: unsafe { std::mem::transmute(guard) },
node,
Expand Down Expand Up @@ -154,13 +154,11 @@ impl<'a> AggregationContext for NodeAggregationContext<'a> {
if self.add_value {
info.value += change.value;
}
Some(change.clone())
Some(*change)
}

fn info_to_add_change(&self, info: &Self::Info) -> Option<Self::ItemChange> {
let change = Change {
value: info.value as i32,
};
let change = Change { value: info.value };
if change.is_empty() {
None
} else {
Expand All @@ -169,9 +167,7 @@ impl<'a> AggregationContext for NodeAggregationContext<'a> {
}

fn info_to_remove_change(&self, info: &Self::Info) -> Option<Self::ItemChange> {
let change = Change {
value: -(info.value as i32),
};
let change = Change { value: -info.value };
if change.is_empty() {
None
} else {
Expand All @@ -184,6 +180,7 @@ impl<'a> AggregationContext for NodeAggregationContext<'a> {
type RootInfoType = ();

fn new_root_info(&self, root_info_type: &Self::RootInfoType) -> Self::RootInfo {
#[allow(clippy::match_single_binding)]
match root_info_type {
() => false,
}
Expand All @@ -194,6 +191,7 @@ impl<'a> AggregationContext for NodeAggregationContext<'a> {
info: &Self::Info,
root_info_type: &Self::RootInfoType,
) -> Self::RootInfo {
#[allow(clippy::match_single_binding)]
match root_info_type {
() => info.active,
}
Expand Down Expand Up @@ -248,7 +246,7 @@ fn chain() {

{
let root_info = leaf.inner.lock().aggregation_leaf.get_root_info(&ctx, &());
assert_eq!(root_info, false);
assert!(!root_info);
}

{
Expand All @@ -262,7 +260,7 @@ fn chain() {

{
let root_info = leaf.inner.lock().aggregation_leaf.get_root_info(&ctx, &());
assert_eq!(root_info, false);
assert!(!root_info);
}

leaf.incr(&ctx);
Expand All @@ -274,14 +272,14 @@ fn chain() {
let aggregated = aggregation_info(&ctx, &current);
let mut aggregated = aggregated.lock();
assert_eq!(aggregated.value, 25050);
(*aggregated).active = true;
aggregated.active = true;
}
assert_eq!(ctx.additions.load(Ordering::SeqCst), 0);
ctx.additions.store(0, Ordering::SeqCst);

{
let root_info = leaf.inner.lock().aggregation_leaf.get_root_info(&ctx, &());
assert_eq!(root_info, true);
assert!(root_info);
}

let i = 101;
Expand Down Expand Up @@ -310,7 +308,7 @@ fn chain() {

{
let root_info = leaf.inner.lock().aggregation_leaf.get_root_info(&ctx, &());
assert_eq!(root_info, true);
assert!(root_info);
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/turbo-tasks-memory/tests/scope_stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use turbo_tasks_testing::register;

register!();

#[allow(clippy::no_effect)] // for *REGISTER
#[test]
fn rectangle_stress() {
*REGISTER;
Expand Down