diff --git a/Cargo.toml b/Cargo.toml index 695381892..65ff1a30a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -171,6 +171,7 @@ suspicious = "deny" # Individual Lints assertions_on_result_states = "deny" +manual_string_new = "deny" semicolon_if_nothing_returned = "deny" undocumented_unsafe_blocks = "deny" uninlined_format_args = "deny" diff --git a/hypervisor/src/arch/emulator/mod.rs b/hypervisor/src/arch/emulator/mod.rs index a882fc8e8..472b712d5 100644 --- a/hypervisor/src/arch/emulator/mod.rs +++ b/hypervisor/src/arch/emulator/mod.rs @@ -26,10 +26,10 @@ impl Display for Exception { self.ip, self.error .map(|e| format!(": error {e:x}")) - .unwrap_or_else(|| "".to_owned()), + .unwrap_or_default(), self.payload .map(|payload| format!(": payload {payload:x}")) - .unwrap_or_else(|| "".to_owned()) + .unwrap_or_default() ) } } diff --git a/performance-metrics/src/main.rs b/performance-metrics/src/main.rs index b3f1ae018..1b374a573 100644 --- a/performance-metrics/src/main.rs +++ b/performance-metrics/src/main.rs @@ -48,7 +48,7 @@ pub struct MetricsReport { impl Default for MetricsReport { fn default() -> Self { - let mut git_human_readable = "".to_string(); + let mut git_human_readable = String::new(); if let Ok(git_out) = Command::new("git").args(["describe", "--dirty"]).output() { if git_out.status.success() { git_human_readable = String::from_utf8(git_out.stdout) @@ -63,7 +63,7 @@ impl Default for MetricsReport { } } - let mut git_revision = "".to_string(); + let mut git_revision = String::new(); if let Ok(git_out) = Command::new("git").args(["rev-parse", "HEAD"]).output() { if git_out.status.success() { git_revision = String::from_utf8(git_out.stdout) @@ -78,7 +78,7 @@ impl Default for MetricsReport { } } - let mut git_commit_date = "".to_string(); + let mut git_commit_date = String::new(); if let Ok(git_out) = Command::new("git") .args(["show", "-s", "--format=%cd"]) .output() diff --git a/tests/integration.rs b/tests/integration.rs index 06a0242dd..4d602bcdb 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -1237,7 +1237,7 @@ fn test_vhost_user_net( if let Some(host_mac) = host_mac { format!(",host_mac={host_mac}") } else { - "".to_owned() + String::new() }, if client_mode_daemon { "server" @@ -1636,7 +1636,7 @@ fn _test_virtio_fs( if let Some(pci_segment) = pci_segment { format!(",pci_segment={pci_segment}") } else { - "".to_owned() + String::new() } ); @@ -1730,7 +1730,7 @@ fn _test_virtio_fs( if let Some(pci_segment) = pci_segment { format!(",pci_segment={pci_segment}") } else { - "".to_owned() + String::new() } ); @@ -2019,7 +2019,7 @@ fn _get_vmm_overhead(pid: u32, guest_memory_size: u32) -> HashMap { let reader = io::BufReader::new(smaps); let mut skip_map: bool = false; - let mut region_name: String = "".to_string(); + let mut region_name: String = String::new(); let mut region_maps = HashMap::new(); for line in reader.lines() { let l = line.unwrap(); @@ -5977,7 +5977,7 @@ mod common_parallel { if let Some(pci_segment) = pci_segment { format!(",pci_segment={pci_segment}") } else { - "".to_owned() + String::new() } )), ); @@ -6109,7 +6109,7 @@ mod common_parallel { if let Some(pci_segment) = pci_segment { format!(",pci_segment={pci_segment}") } else { - "".to_owned() + String::new() } ) .as_str(), @@ -6172,7 +6172,7 @@ mod common_parallel { if let Some(pci_segment) = pci_segment { format!(",pci_segment={pci_segment}") } else { - "".to_owned() + String::new() } ) .as_str(), diff --git a/vmm/src/config.rs b/vmm/src/config.rs index 8b1f940b0..8378a7a31 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -4681,7 +4681,7 @@ mod unit_tests { // Test empty string serial (should be valid) let mut empty_serial_config = valid_config.clone(); empty_serial_config.disks = Some(vec![DiskConfig { - serial: Some("".to_string()), + serial: Some(String::new()), ..disk_fixture() }]); empty_serial_config.validate().unwrap(); @@ -4755,7 +4755,7 @@ mod unit_tests { #[cfg(feature = "igvm")] igvm: None, #[cfg(feature = "sev_snp")] - host_data: Some("".to_string()), + host_data: Some(String::new()), #[cfg(feature = "fw_cfg")] fw_cfg_config: None, });