From 9bfad8f2a50603fad12e8f1654dbdfc57ea2a7cb Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Mon, 2 Dec 2024 10:13:35 -0500 Subject: [PATCH] Fix Rust 1.83 clippy errors Fix 29 "needless_lifetimes" errors, and one error in a test, for "implicit_saturating_sub", in strat_engine/tests/real.rs. Signed-off-by: Bryan Gurney --- src/engine/sim_engine/blockdev.rs | 2 +- src/engine/sim_engine/engine.rs | 2 +- src/engine/sim_engine/filesystem.rs | 2 +- src/engine/sim_engine/pool.rs | 2 +- src/engine/strat_engine/backstore/backstore/v1.rs | 2 +- src/engine/strat_engine/backstore/backstore/v2.rs | 2 +- src/engine/strat_engine/backstore/blockdev/v1.rs | 4 ++-- src/engine/strat_engine/backstore/blockdev/v2.rs | 4 ++-- src/engine/strat_engine/backstore/range_alloc.rs | 2 +- src/engine/strat_engine/engine.rs | 2 +- src/engine/strat_engine/liminal/device_info.rs | 10 +++++----- src/engine/strat_engine/liminal/identify.rs | 2 +- src/engine/strat_engine/liminal/liminal.rs | 2 +- src/engine/strat_engine/metadata/static_header.rs | 2 +- src/engine/strat_engine/pool/v1.rs | 4 ++-- src/engine/strat_engine/pool/v2.rs | 4 ++-- src/engine/strat_engine/tests/real.rs | 2 +- src/engine/strat_engine/thinpool/filesystem.rs | 4 ++-- src/engine/strat_engine/thinpool/thinpool.rs | 2 +- src/engine/types/keys.rs | 4 ++-- 20 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/engine/sim_engine/blockdev.rs b/src/engine/sim_engine/blockdev.rs index cd63aca3a7..9886a3ad4e 100644 --- a/src/engine/sim_engine/blockdev.rs +++ b/src/engine/sim_engine/blockdev.rs @@ -87,7 +87,7 @@ impl SimDev { } } -impl<'a> Into for &'a SimDev { +impl Into for &SimDev { fn into(self) -> Value { let mut json = Map::new(); json.insert( diff --git a/src/engine/sim_engine/engine.rs b/src/engine/sim_engine/engine.rs index 45f2a034a7..1761c2c7e9 100644 --- a/src/engine/sim_engine/engine.rs +++ b/src/engine/sim_engine/engine.rs @@ -51,7 +51,7 @@ impl Default for SimEngine { } } -impl<'a> Into for &'a SimEngine { +impl Into for &SimEngine { // Precondition: SimPool Into impl return value always pattern matches // Value::Object(_) fn into(self) -> Value { diff --git a/src/engine/sim_engine/filesystem.rs b/src/engine/sim_engine/filesystem.rs index 2699dc70a3..4cbb4fdd18 100644 --- a/src/engine/sim_engine/filesystem.rs +++ b/src/engine/sim_engine/filesystem.rs @@ -156,7 +156,7 @@ impl Filesystem for SimFilesystem { } } -impl<'a> Into for &'a SimFilesystem { +impl Into for &SimFilesystem { fn into(self) -> Value { let mut json = Map::new(); json.insert("size".to_string(), Value::from(self.size().to_string())); diff --git a/src/engine/sim_engine/pool.rs b/src/engine/sim_engine/pool.rs index 1ad5f6ef17..3edc16d0f7 100644 --- a/src/engine/sim_engine/pool.rs +++ b/src/engine/sim_engine/pool.rs @@ -136,7 +136,7 @@ impl SimPool { // Precondition: SimDev::into() always returns a value that matches Value::Object(_). // Precondition: SimFilesystem::into() always returns a value that matches Value::Object(_). -impl<'a> Into for &'a SimPool { +impl Into for &SimPool { fn into(self) -> Value { json!({ "available_actions": ActionAvailability::Full.to_string(), diff --git a/src/engine/strat_engine/backstore/backstore/v1.rs b/src/engine/strat_engine/backstore/backstore/v1.rs index 136df42bb8..a9c5cb5a27 100644 --- a/src/engine/strat_engine/backstore/backstore/v1.rs +++ b/src/engine/strat_engine/backstore/backstore/v1.rs @@ -944,7 +944,7 @@ impl Backstore { } } -impl<'a> Into for &'a Backstore { +impl Into for &Backstore { fn into(self) -> Value { json!({ "blockdevs": { diff --git a/src/engine/strat_engine/backstore/backstore/v2.rs b/src/engine/strat_engine/backstore/backstore/v2.rs index 56e970437c..3034098fe0 100644 --- a/src/engine/strat_engine/backstore/backstore/v2.rs +++ b/src/engine/strat_engine/backstore/backstore/v2.rs @@ -1132,7 +1132,7 @@ impl Backstore { } } -impl<'a> Into for &'a Backstore { +impl Into for &Backstore { fn into(self) -> Value { json!({ "blockdevs": { diff --git a/src/engine/strat_engine/backstore/blockdev/v1.rs b/src/engine/strat_engine/backstore/blockdev/v1.rs index ffbd71dcc6..f5002cd952 100644 --- a/src/engine/strat_engine/backstore/blockdev/v1.rs +++ b/src/engine/strat_engine/backstore/blockdev/v1.rs @@ -533,7 +533,7 @@ impl InternalBlockDev for StratBlockDev { } } -impl<'a> Into for &'a StratBlockDev { +impl Into for &StratBlockDev { fn into(self) -> Value { let mut json = json!({ "path": self.underlying_device.physical_path(), @@ -630,7 +630,7 @@ impl StateDiff for StratBlockDevState { } } -impl<'a> DumpState<'a> for StratBlockDev { +impl DumpState<'_> for StratBlockDev { type State = StratBlockDevState; type DumpInput = Sectors; diff --git a/src/engine/strat_engine/backstore/blockdev/v2.rs b/src/engine/strat_engine/backstore/blockdev/v2.rs index 985c110fe6..4c872b0cb6 100644 --- a/src/engine/strat_engine/backstore/blockdev/v2.rs +++ b/src/engine/strat_engine/backstore/blockdev/v2.rs @@ -351,7 +351,7 @@ impl InternalBlockDev for StratBlockDev { } } -impl<'a> Into for &'a StratBlockDev { +impl Into for &StratBlockDev { fn into(self) -> Value { let mut json = json!({ "path": self.devnode(), @@ -436,7 +436,7 @@ impl StateDiff for StratBlockDevState { } } -impl<'a> DumpState<'a> for StratBlockDev { +impl DumpState<'_> for StratBlockDev { type State = StratBlockDevState; type DumpInput = Sectors; diff --git a/src/engine/strat_engine/backstore/range_alloc.rs b/src/engine/strat_engine/backstore/range_alloc.rs index 5dc2c71ee1..be775a7bea 100644 --- a/src/engine/strat_engine/backstore/range_alloc.rs +++ b/src/engine/strat_engine/backstore/range_alloc.rs @@ -315,7 +315,7 @@ impl<'a> Iterator for Iter<'a> { } } -impl<'a> DoubleEndedIterator for Iter<'a> { +impl DoubleEndedIterator for Iter<'_> { fn next_back(&mut self) -> Option { self.items.next_back() } diff --git a/src/engine/strat_engine/engine.rs b/src/engine/strat_engine/engine.rs index c539805a5d..8c4fb8c504 100644 --- a/src/engine/strat_engine/engine.rs +++ b/src/engine/strat_engine/engine.rs @@ -360,7 +360,7 @@ impl StratEngine { } } -impl<'a> Into for &'a StratEngine { +impl Into for &StratEngine { // Precondition: (&StratPool).into() pattern matches Value::Object(_) // Precondition: (&LiminalDevices).into() pattern matches Value::Object(_) fn into(self) -> Value { diff --git a/src/engine/strat_engine/liminal/device_info.rs b/src/engine/strat_engine/liminal/device_info.rs index ec89be4bd9..aeec10ac24 100644 --- a/src/engine/strat_engine/liminal/device_info.rs +++ b/src/engine/strat_engine/liminal/device_info.rs @@ -68,7 +68,7 @@ impl From for LLuksInfo { } } -impl<'a> Into for &'a LLuksInfo { +impl Into for &LLuksInfo { // Precondition: (&StratisInfo).into() pattern matches Value::Object() // Precondition: (&EncryptionInfo).into() pattern matches Value::Object() fn into(self) -> Value { @@ -236,7 +236,7 @@ impl From for LStratisInfo { } } -impl<'a> Into for &'a LStratisInfo { +impl Into for &LStratisInfo { // Precondition: (&StratisInfo).into() pattern matches Value::Object() // Precondition: (&LLuksInfo).into() pattern matches Value::Object() fn into(self) -> Value { @@ -310,7 +310,7 @@ impl From for LInfo { } } -impl<'a> Into for &'a LInfo { +impl Into for &LInfo { // Precondition: (&LStratisInfo).into() pattern matches Value::Object() // Precondition: (&LLuksInfo).into() pattern matches Value::Object() fn into(self) -> Value { @@ -820,7 +820,7 @@ impl DeviceSet { } } -impl<'a> Into for &'a DeviceSet { +impl Into for &DeviceSet { fn into(self) -> Value { Value::Array(self.internal.values().map(|info| info.into()).collect()) } @@ -851,7 +851,7 @@ impl DeviceBag { } } -impl<'a> Into for &'a DeviceBag { +impl Into for &DeviceBag { fn into(self) -> Value { Value::Array(self.internal.iter().map(|info| info.into()).collect()) } diff --git a/src/engine/strat_engine/liminal/identify.rs b/src/engine/strat_engine/liminal/identify.rs index d89318f91a..864a959953 100644 --- a/src/engine/strat_engine/liminal/identify.rs +++ b/src/engine/strat_engine/liminal/identify.rs @@ -71,7 +71,7 @@ pub struct StratisDevInfo { pub devnode: PathBuf, } -impl<'a> Into for &'a StratisDevInfo { +impl Into for &StratisDevInfo { // Precondition: (&StratisIdentifiers).into() pattern matches // Value::Object() fn into(self) -> Value { diff --git a/src/engine/strat_engine/liminal/liminal.rs b/src/engine/strat_engine/liminal/liminal.rs index 6dfdf75480..73e9496ed2 100644 --- a/src/engine/strat_engine/liminal/liminal.rs +++ b/src/engine/strat_engine/liminal/liminal.rs @@ -1183,7 +1183,7 @@ impl LiminalDevices { } } -impl<'a> Into for &'a LiminalDevices { +impl Into for &LiminalDevices { fn into(self) -> Value { json!({ "stopped_pools": Value::Array( diff --git a/src/engine/strat_engine/metadata/static_header.rs b/src/engine/strat_engine/metadata/static_header.rs index 195562d1b7..f9c3f9a47a 100644 --- a/src/engine/strat_engine/metadata/static_header.rs +++ b/src/engine/strat_engine/metadata/static_header.rs @@ -88,7 +88,7 @@ impl fmt::Display for StratisIdentifiers { } } -impl<'a> Into for &'a StratisIdentifiers { +impl Into for &StratisIdentifiers { fn into(self) -> Value { json!({ "pool_uuid": Value::from(self.pool_uuid.to_string()), diff --git a/src/engine/strat_engine/pool/v1.rs b/src/engine/strat_engine/pool/v1.rs index 984e1c33a4..8be06f304c 100644 --- a/src/engine/strat_engine/pool/v1.rs +++ b/src/engine/strat_engine/pool/v1.rs @@ -516,7 +516,7 @@ impl StratPool { } } -impl<'a> Into for &'a StratPool { +impl Into for &StratPool { // Precondition: (&ThinPool).into() pattern matches Value::Object(_) // Precondition: (&Backstore).into() pattern matches Value::Object(_) fn into(self) -> Value { @@ -1319,7 +1319,7 @@ impl StateDiff for StratPoolState { } } -impl<'a> DumpState<'a> for StratPool { +impl DumpState<'_> for StratPool { type State = StratPoolState; type DumpInput = (); diff --git a/src/engine/strat_engine/pool/v2.rs b/src/engine/strat_engine/pool/v2.rs index d0990011b4..d28c5a1831 100644 --- a/src/engine/strat_engine/pool/v2.rs +++ b/src/engine/strat_engine/pool/v2.rs @@ -485,7 +485,7 @@ impl StratPool { } } -impl<'a> Into for &'a StratPool { +impl Into for &StratPool { // Precondition: (&ThinPool).into() pattern matches Value::Object(_) // Precondition: (&Backstore).into() pattern matches Value::Object(_) fn into(self) -> Value { @@ -1219,7 +1219,7 @@ impl StateDiff for StratPoolState { } } -impl<'a> DumpState<'a> for StratPool { +impl DumpState<'_> for StratPool { type State = StratPoolState; type DumpInput = (); diff --git a/src/engine/strat_engine/tests/real.rs b/src/engine/strat_engine/tests/real.rs index e0d88a203c..cbcfc48d72 100644 --- a/src/engine/strat_engine/tests/real.rs +++ b/src/engine/strat_engine/tests/real.rs @@ -125,7 +125,7 @@ fn get_device_runs<'a>( let avail = matches.len(); let needed = maybe_upper.unwrap_or(lower); - let must_generate = if avail > needed { 0 } else { needed - avail }; + let must_generate = needed.saturating_sub(avail); let avail_specs = { let mut avail_specs = vec![]; while avail_specs.len() < must_generate && (!too_large.is_empty() || !matches.is_empty()) { diff --git a/src/engine/strat_engine/thinpool/filesystem.rs b/src/engine/strat_engine/thinpool/filesystem.rs index 8e833cbbf0..d92f9673dd 100644 --- a/src/engine/strat_engine/thinpool/filesystem.rs +++ b/src/engine/strat_engine/thinpool/filesystem.rs @@ -545,7 +545,7 @@ impl StateDiff for StratFilesystemState { } } } -impl<'a> DumpState<'a> for StratFilesystem { +impl DumpState<'_> for StratFilesystem { type State = StratFilesystemState; type DumpInput = (); @@ -582,7 +582,7 @@ pub fn fs_usage(mount_point: &Path) -> StratisResult<(Bytes, Bytes)> { )) } -impl<'a> Into for &'a StratFilesystem { +impl Into for &StratFilesystem { fn into(self) -> Value { let mut json = Map::new(); json.insert( diff --git a/src/engine/strat_engine/thinpool/thinpool.rs b/src/engine/strat_engine/thinpool/thinpool.rs index 54901aaa77..aea8df8a71 100644 --- a/src/engine/strat_engine/thinpool/thinpool.rs +++ b/src/engine/strat_engine/thinpool/thinpool.rs @@ -1923,7 +1923,7 @@ where } } -impl<'a, B> Into for &'a ThinPool { +impl Into for &ThinPool { fn into(self) -> Value { json!({ "filesystems": Value::Array( diff --git a/src/engine/types/keys.rs b/src/engine/types/keys.rs index f291cb729c..f147f28f42 100644 --- a/src/engine/types/keys.rs +++ b/src/engine/types/keys.rs @@ -149,7 +149,7 @@ impl Hash for EncryptionInfo { } } -impl<'a> Into for &'a EncryptionInfo { +impl Into for &EncryptionInfo { fn into(self) -> Value { let mut json = Map::new(); if let Some(kd) = self.key_description() { @@ -369,7 +369,7 @@ impl TryFrom for KeyDescription { } } -impl<'a> TryFrom<&'a String> for KeyDescription { +impl TryFrom<&String> for KeyDescription { type Error = StratisError; fn try_from(s: &String) -> StratisResult {