Skip to content

Commit 8fc9dde

Browse files
ShadowCurseroypat
andcommitted
chore(clippy): update code with new lints
From: Egor Lazarchuk <[email protected]> With a new Rust version, new Clippy entered our repository. This commit aligns our codebase with guidance provided by new lints. Also remove a `deny(clippy::pedantic)`, because I'm not fixing those. (cherry picked from commit c5e5794) Signed-off-by: Egor Lazarchuk <[email protected]> Co-authored-by: Patrick Roy <[email protected]> Signed-off-by: Patrick Roy <[email protected]>
1 parent 139b1b1 commit 8fc9dde

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+128
-155
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ resolver = "2"
99

1010
[workspace.lints.rust]
1111
missing_debug_implementations = "warn"
12+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(kani)'] }
1213

1314
[workspace.lints.clippy]
1415
ptr_as_ptr = "warn"

src/acpi-tables/src/aml.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ pub struct Package<'a> {
180180
children: Vec<&'a dyn Aml>,
181181
}
182182

183-
impl<'a> Aml for Package<'a> {
183+
impl Aml for Package<'_> {
184184
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
185185
let mut tmp = vec![self.children.len().try_into().unwrap()];
186186
for child in &self.children {
@@ -336,7 +336,7 @@ pub struct ResourceTemplate<'a> {
336336
children: Vec<&'a dyn Aml>,
337337
}
338338

339-
impl<'a> Aml for ResourceTemplate<'a> {
339+
impl Aml for ResourceTemplate<'_> {
340340
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
341341
let mut tmp = Vec::new();
342342
// Add buffer data
@@ -607,7 +607,7 @@ pub struct Device<'a> {
607607
children: Vec<&'a dyn Aml>,
608608
}
609609

610-
impl<'a> Aml for Device<'a> {
610+
impl Aml for Device<'_> {
611611
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
612612
let mut tmp = Vec::new();
613613
self.path.append_aml_bytes(&mut tmp)?;
@@ -637,7 +637,7 @@ pub struct Scope<'a> {
637637
children: Vec<&'a dyn Aml>,
638638
}
639639

640-
impl<'a> Aml for Scope<'a> {
640+
impl Aml for Scope<'_> {
641641
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
642642
let mut tmp = Vec::new();
643643
self.path.append_aml_bytes(&mut tmp)?;
@@ -678,7 +678,7 @@ impl<'a> Method<'a> {
678678
}
679679
}
680680

681-
impl<'a> Aml for Method<'a> {
681+
impl Aml for Method<'_> {
682682
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
683683
let mut tmp = Vec::new();
684684
self.path.append_aml_bytes(&mut tmp)?;
@@ -707,7 +707,7 @@ impl<'a> Return<'a> {
707707
}
708708
}
709709

710-
impl<'a> Aml for Return<'a> {
710+
impl Aml for Return<'_> {
711711
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
712712
bytes.push(0xa4); // ReturnOp
713713
self.value.append_aml_bytes(bytes)?;
@@ -850,7 +850,7 @@ impl<'a> If<'a> {
850850
}
851851
}
852852

853-
impl<'a> Aml for If<'a> {
853+
impl Aml for If<'_> {
854854
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
855855
let mut tmp = Vec::new();
856856
self.predicate.append_aml_bytes(&mut tmp)?;
@@ -878,7 +878,7 @@ impl<'a> Equal<'a> {
878878
}
879879
}
880880

881-
impl<'a> Aml for Equal<'a> {
881+
impl Aml for Equal<'_> {
882882
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
883883
bytes.push(0x93); // LEqualOp
884884
self.left.append_aml_bytes(bytes)?;
@@ -898,7 +898,7 @@ impl<'a> LessThan<'a> {
898898
}
899899
}
900900

901-
impl<'a> Aml for LessThan<'a> {
901+
impl Aml for LessThan<'_> {
902902
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
903903
bytes.push(0x95); // LLessOp
904904
self.left.append_aml_bytes(bytes)?;
@@ -942,7 +942,7 @@ impl<'a> Store<'a> {
942942
}
943943
}
944944

945-
impl<'a> Aml for Store<'a> {
945+
impl Aml for Store<'_> {
946946
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
947947
bytes.push(0x70); // StoreOp
948948
self.value.append_aml_bytes(bytes)?;
@@ -1023,7 +1023,7 @@ impl<'a> Notify<'a> {
10231023
}
10241024
}
10251025

1026-
impl<'a> Aml for Notify<'a> {
1026+
impl Aml for Notify<'_> {
10271027
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
10281028
bytes.push(0x86); // NotifyOp
10291029
self.object.append_aml_bytes(bytes)?;
@@ -1046,7 +1046,7 @@ impl<'a> While<'a> {
10461046
}
10471047
}
10481048

1049-
impl<'a> Aml for While<'a> {
1049+
impl Aml for While<'_> {
10501050
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
10511051
let mut tmp = Vec::new();
10521052
self.predicate.append_aml_bytes(&mut tmp)?;
@@ -1116,7 +1116,7 @@ impl<'a> MethodCall<'a> {
11161116
}
11171117
}
11181118

1119-
impl<'a> Aml for MethodCall<'a> {
1119+
impl Aml for MethodCall<'_> {
11201120
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
11211121
self.name.append_aml_bytes(bytes)?;
11221122
for arg in self.args.iter() {
@@ -1169,7 +1169,7 @@ impl<'a, T> CreateField<'a, T> {
11691169
}
11701170
}
11711171

1172-
impl<'a> Aml for CreateField<'a, u64> {
1172+
impl Aml for CreateField<'_, u64> {
11731173
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
11741174
bytes.push(0x8f); // CreateQWordFieldOp
11751175
self.buffer.append_aml_bytes(bytes)?;
@@ -1178,7 +1178,7 @@ impl<'a> Aml for CreateField<'a, u64> {
11781178
}
11791179
}
11801180

1181-
impl<'a> Aml for CreateField<'a, u32> {
1181+
impl Aml for CreateField<'_, u32> {
11821182
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), AmlError> {
11831183
bytes.push(0x8a); // CreateDWordFieldOp
11841184
self.buffer.append_aml_bytes(bytes)?;

src/clippy-tracing/src/main.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
#![warn(clippy::pedantic)]
5-
64
//! A tool to add, remove and check for `tracing::instrument` in large projects where it is
75
//! infeasible to manually add it to thousands of functions.
86

src/firecracker/src/api_server/request/actions.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ struct ActionBody {
3030

3131
pub(crate) fn parse_put_actions(body: &Body) -> Result<ParsedRequest, RequestError> {
3232
METRICS.put_api_requests.actions_count.inc();
33-
let action_body = serde_json::from_slice::<ActionBody>(body.raw()).map_err(|err| {
33+
let action_body = serde_json::from_slice::<ActionBody>(body.raw()).inspect_err(|_| {
3434
METRICS.put_api_requests.actions_fails.inc();
35-
err
3635
})?;
3736

3837
match action_body.action_type {

src/firecracker/src/api_server/request/boot_source.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ use super::Body;
1111
pub(crate) fn parse_put_boot_source(body: &Body) -> Result<ParsedRequest, RequestError> {
1212
METRICS.put_api_requests.boot_source_count.inc();
1313
Ok(ParsedRequest::new_sync(VmmAction::ConfigureBootSource(
14-
serde_json::from_slice::<BootSourceConfig>(body.raw()).map_err(|err| {
14+
serde_json::from_slice::<BootSourceConfig>(body.raw()).inspect_err(|_| {
1515
METRICS.put_api_requests.boot_source_fails.inc();
16-
err
1716
})?,
1817
)))
1918
}

src/firecracker/src/api_server/request/drive.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ pub(crate) fn parse_put_drive(
2020
return Err(RequestError::EmptyID);
2121
};
2222

23-
let device_cfg = serde_json::from_slice::<BlockDeviceConfig>(body.raw()).map_err(|err| {
23+
let device_cfg = serde_json::from_slice::<BlockDeviceConfig>(body.raw()).inspect_err(|_| {
2424
METRICS.put_api_requests.drive_fails.inc();
25-
err
2625
})?;
2726

2827
if id != device_cfg.drive_id {
@@ -51,9 +50,8 @@ pub(crate) fn parse_patch_drive(
5150
};
5251

5352
let block_device_update_cfg: BlockDeviceUpdateConfig =
54-
serde_json::from_slice::<BlockDeviceUpdateConfig>(body.raw()).map_err(|err| {
53+
serde_json::from_slice::<BlockDeviceUpdateConfig>(body.raw()).inspect_err(|_| {
5554
METRICS.patch_api_requests.drive_fails.inc();
56-
err
5755
})?;
5856

5957
if id != block_device_update_cfg.drive_id {

src/firecracker/src/api_server/request/logger.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ use super::Body;
1010
pub(crate) fn parse_put_logger(body: &Body) -> Result<ParsedRequest, RequestError> {
1111
METRICS.put_api_requests.logger_count.inc();
1212
let res = serde_json::from_slice::<vmm::logger::LoggerConfig>(body.raw());
13-
let config = res.map_err(|err| {
13+
let config = res.inspect_err(|_| {
1414
METRICS.put_api_requests.logger_fails.inc();
15-
err
1615
})?;
1716
Ok(ParsedRequest::new_sync(VmmAction::ConfigureLogger(config)))
1817
}

src/firecracker/src/api_server/request/machine_configuration.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ pub(crate) fn parse_get_machine_config() -> Result<ParsedRequest, RequestError>
1515

1616
pub(crate) fn parse_put_machine_config(body: &Body) -> Result<ParsedRequest, RequestError> {
1717
METRICS.put_api_requests.machine_cfg_count.inc();
18-
let config = serde_json::from_slice::<MachineConfig>(body.raw()).map_err(|err| {
18+
let config = serde_json::from_slice::<MachineConfig>(body.raw()).inspect_err(|_| {
1919
METRICS.put_api_requests.machine_cfg_fails.inc();
20-
err
2120
})?;
2221

2322
// Check for the presence of deprecated `cpu_template` field.
@@ -44,9 +43,8 @@ pub(crate) fn parse_put_machine_config(body: &Body) -> Result<ParsedRequest, Req
4443
pub(crate) fn parse_patch_machine_config(body: &Body) -> Result<ParsedRequest, RequestError> {
4544
METRICS.patch_api_requests.machine_cfg_count.inc();
4645
let config_update =
47-
serde_json::from_slice::<MachineConfigUpdate>(body.raw()).map_err(|err| {
46+
serde_json::from_slice::<MachineConfigUpdate>(body.raw()).inspect_err(|_| {
4847
METRICS.patch_api_requests.machine_cfg_fails.inc();
49-
err
5048
})?;
5149

5250
if config_update.is_empty() {

src/firecracker/src/api_server/request/metrics.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ use super::Body;
1111
pub(crate) fn parse_put_metrics(body: &Body) -> Result<ParsedRequest, RequestError> {
1212
METRICS.put_api_requests.metrics_count.inc();
1313
Ok(ParsedRequest::new_sync(VmmAction::ConfigureMetrics(
14-
serde_json::from_slice::<MetricsConfig>(body.raw()).map_err(|err| {
14+
serde_json::from_slice::<MetricsConfig>(body.raw()).inspect_err(|_| {
1515
METRICS.put_api_requests.metrics_fails.inc();
16-
err
1716
})?,
1817
)))
1918
}

src/firecracker/src/api_server/request/mmds.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ pub(crate) fn parse_get_mmds() -> Result<ParsedRequest, RequestError> {
1616
}
1717

1818
fn parse_put_mmds_config(body: &Body) -> Result<ParsedRequest, RequestError> {
19-
let config: MmdsConfig = serde_json::from_slice(body.raw()).map_err(|err| {
19+
let config: MmdsConfig = serde_json::from_slice(body.raw()).inspect_err(|_| {
2020
METRICS.put_api_requests.mmds_fails.inc();
21-
err
2221
})?;
2322
// Construct the `ParsedRequest` object.
2423
let version = config.version;
@@ -42,9 +41,8 @@ pub(crate) fn parse_put_mmds(
4241
METRICS.put_api_requests.mmds_count.inc();
4342
match path_second_token {
4443
None => Ok(ParsedRequest::new_sync(VmmAction::PutMMDS(
45-
serde_json::from_slice(body.raw()).map_err(|err| {
44+
serde_json::from_slice(body.raw()).inspect_err(|_| {
4645
METRICS.put_api_requests.mmds_fails.inc();
47-
err
4846
})?,
4947
))),
5048
Some("config") => parse_put_mmds_config(body),
@@ -61,9 +59,8 @@ pub(crate) fn parse_put_mmds(
6159
pub(crate) fn parse_patch_mmds(body: &Body) -> Result<ParsedRequest, RequestError> {
6260
METRICS.patch_api_requests.mmds_count.inc();
6361
Ok(ParsedRequest::new_sync(VmmAction::PatchMMDS(
64-
serde_json::from_slice(body.raw()).map_err(|err| {
62+
serde_json::from_slice(body.raw()).inspect_err(|_| {
6563
METRICS.patch_api_requests.mmds_fails.inc();
66-
err
6764
})?,
6865
)))
6966
}

0 commit comments

Comments
 (0)