Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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]
Tested-by: Benno Lossin <benno.lossin@proton.me>
Tested-by: Andreas Hindborg <a.hindborg@samsung.com>
Link: https://lore.kernel.org/r/20240709160615.998336-3-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

+4 -9
+4 -9
rust/kernel/init.rs
··· 843 843 let val = unsafe { &mut *slot }; 844 844 // SAFETY: `slot` is considered pinned. 845 845 let val = unsafe { Pin::new_unchecked(val) }; 846 - (self.1)(val).map_err(|e| { 847 - // SAFETY: `slot` was initialized above. 848 - unsafe { core::ptr::drop_in_place(slot) }; 849 - e 850 - }) 846 + // SAFETY: `slot` was initialized above. 847 + (self.1)(val).inspect_err(|_| unsafe { core::ptr::drop_in_place(slot) }) 851 848 } 852 849 } 853 850 ··· 938 941 // SAFETY: All requirements fulfilled since this function is `__init`. 939 942 unsafe { self.0.__pinned_init(slot)? }; 940 943 // SAFETY: The above call initialized `slot` and we still have unique access. 941 - (self.1)(unsafe { &mut *slot }).map_err(|e| { 944 + (self.1)(unsafe { &mut *slot }).inspect_err(|_| 942 945 // SAFETY: `slot` was initialized above. 943 - unsafe { core::ptr::drop_in_place(slot) }; 944 - e 945 - }) 946 + unsafe { core::ptr::drop_in_place(slot) }) 946 947 } 947 948 } 948 949