Skip to content

Commit da24ec2

Browse files
ojedafbq
authored andcommitted
rust: init: simplify from map_err to inspect_err
A new complexity lint, `manual_inspect` [1], has been introduced in the upcoming Rust 1.81 (currently in nightly), which checks for uses of `map*` which return the original item: error: --> rust/kernel/init.rs:846:23 | 846 | (self.1)(val).map_err(|e| { | ^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_inspect = note: `-D clippy::manual-inspect` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::manual_inspect)]` help: try | 846 ~ (self.1)(val).inspect_err(|e| { 847 | // SAFETY: `slot` was initialized above. 848 ~ unsafe { core::ptr::drop_in_place(slot) }; | Thus clean them up. Link: https://rust-lang.github.io/rust-clippy/master/index.html#/manual_inspect [1] Signed-off-by: Miguel Ojeda <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 276856a commit da24ec2

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

rust/kernel/init.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -843,11 +843,9 @@ where
843843
let val = unsafe { &mut *slot };
844844
// SAFETY: `slot` is considered pinned.
845845
let val = unsafe { Pin::new_unchecked(val) };
846-
(self.1)(val).map_err(|e| {
846+
(self.1)(val).inspect_err(|_|
847847
// SAFETY: `slot` was initialized above.
848-
unsafe { core::ptr::drop_in_place(slot) };
849-
e
850-
})
848+
unsafe { core::ptr::drop_in_place(slot) })
851849
}
852850
}
853851

@@ -941,11 +939,9 @@ where
941939
// SAFETY: All requirements fulfilled since this function is `__init`.
942940
unsafe { self.0.__pinned_init(slot)? };
943941
// SAFETY: The above call initialized `slot` and we still have unique access.
944-
(self.1)(unsafe { &mut *slot }).map_err(|e| {
942+
(self.1)(unsafe { &mut *slot }).inspect_err(|_|
945943
// SAFETY: `slot` was initialized above.
946-
unsafe { core::ptr::drop_in_place(slot) };
947-
e
948-
})
944+
unsafe { core::ptr::drop_in_place(slot) })
949945
}
950946
}
951947

0 commit comments

Comments
 (0)