Skip to content

Commit

Permalink
rust: sync: implement Default for LockClassKey
Browse files Browse the repository at this point in the history
In the upcoming Rust 1.78.0, Clippy suggests to implement `Default` even
when `new()` is `const`, since `Default::default()` may call `const`
functions even if it is not `const` itself [1]:

    error: you should consider adding a `Default` implementation for `LockClassKey`
      --> rust/kernel/sync.rs:31:5
       |
    31 | /     pub const fn new() -> Self {
    32 | |         Self(Opaque::uninit())
    33 | |     }
       | |_____^

Thus implement it.

Link: rust-lang/rust-clippy#10903 [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
  • Loading branch information
ojeda committed Apr 1, 2024
1 parent b9b379f commit c11d24c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rust/kernel/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ impl LockClassKey {
}
}

impl Default for LockClassKey {
fn default() -> Self {
Self::new()
}
}

/// Defines a new static lock class and returns a pointer to it.
#[doc(hidden)]
#[macro_export]
Expand Down

0 comments on commit c11d24c

Please sign in to comment.