]> www.infradead.org Git - users/dwmw2/linux.git/commit
rust: init: simplify from `map_err` to `inspect_err`
authorMiguel Ojeda <ojeda@kernel.org>
Tue, 9 Jul 2024 16:05:57 +0000 (18:05 +0200)
committerMiguel Ojeda <ojeda@kernel.org>
Wed, 10 Jul 2024 08:28:51 +0000 (10:28 +0200)
commitdee1396a486cf2b6e7840322f6d104680649f2ff
tree6819264f0af1d9d97984262f03550a057b2383fd
parente516211f615fb54ce3429870eefc17469ae289b8
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
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>
rust/kernel/init.rs