Skip to content

Commit 29e8495

Browse files
authored
chore: Enable assigning_clones clippy lint (#20670)
## Which issue does this PR close? N/A ## Rationale for this change The `assigning_clones` clippy lint seems marginally useful. Enabling it for the whole workspace only catches a few places, but they are all coding patterns that could be improved. ## What changes are included in this PR? - Enable `assigning_clones` clippy lint as a workspace-level warning - Fix existing lint violations (no false positives) ## Are these changes tested? Yes, covered by existing tests. This is a mechanical refactor that does not change behavior. ## Are there any user-facing changes? No.
1 parent 46ac990 commit 29e8495

4 files changed

Lines changed: 11 additions & 15 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ inefficient_to_string = "warn"
208208
needless_pass_by_value = "warn"
209209
# https://github.com/apache/datafusion/issues/18881
210210
allow_attributes = "warn"
211+
assigning_clones = "warn"
211212

212213
[workspace.lints.rust]
213214
unexpected_cfgs = { level = "warn", check-cfg = [

datafusion/common/src/config.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2711,10 +2711,7 @@ impl From<&Arc<FileEncryptionProperties>> for ConfigFileEncryptionProperties {
27112711
},
27122712
);
27132713
}
2714-
let mut aad_prefix: Vec<u8> = Vec::new();
2715-
if let Some(prefix) = f.aad_prefix() {
2716-
aad_prefix = prefix.clone();
2717-
}
2714+
let aad_prefix = f.aad_prefix().cloned().unwrap_or_default();
27182715
ConfigFileEncryptionProperties {
27192716
encrypt_footer: f.encrypt_footer(),
27202717
footer_key_as_hex: hex::encode(f.footer_key()),
@@ -2852,10 +2849,7 @@ impl From<&Arc<FileDecryptionProperties>> for ConfigFileDecryptionProperties {
28522849
column_decryption_properties.insert(column_name.clone(), props);
28532850
}
28542851

2855-
let mut aad_prefix: Vec<u8> = Vec::new();
2856-
if let Some(prefix) = f.aad_prefix() {
2857-
aad_prefix = prefix.clone();
2858-
}
2852+
let aad_prefix = f.aad_prefix().cloned().unwrap_or_default();
28592853
ConfigFileDecryptionProperties {
28602854
footer_key_as_hex: hex::encode(
28612855
f.footer_key(None).unwrap_or_default().as_ref(),

datafusion/physical-plan/src/aggregates/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ impl ExecutionPlan for AggregateExec {
14291429
Arc::clone(&self.schema),
14301430
)?;
14311431
me.limit_options = self.limit_options;
1432-
me.dynamic_filter = self.dynamic_filter.clone();
1432+
me.dynamic_filter.clone_from(&self.dynamic_filter);
14331433

14341434
Ok(Arc::new(me))
14351435
}

datafusion/physical-plan/src/display.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -734,13 +734,14 @@ impl TreeRenderVisitor<'_, '_> {
734734
if let Some(node) = root.get_node(x, y) {
735735
write!(self.f, "{}", Self::VERTICAL)?;
736736

737-
// Rigure out what to render.
738-
let mut render_text = String::new();
739-
if render_y == 0 {
740-
render_text = node.name.clone();
737+
// Figure out what to render.
738+
let mut render_text = if render_y == 0 {
739+
node.name.clone()
741740
} else if render_y <= extra_info[x].len() {
742-
render_text = extra_info[x][render_y - 1].clone();
743-
}
741+
extra_info[x][render_y - 1].clone()
742+
} else {
743+
String::new()
744+
};
744745

745746
render_text = Self::adjust_text_for_rendering(
746747
&render_text,

0 commit comments

Comments
 (0)