From: Boqun Feng <boqun.feng@gmail.com>
To: Miguel Ojeda <ojeda@kernel.org>
Cc: "Wedson Almeida Filho" <wedsonaf@gmail.com>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@samsung.com>,
"Alice Ryhl" <aliceryhl@google.com>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@lists.linux.dev
Subject: Re: [PATCH 1/3] rust: sync: implement `Default` for `LockClassKey`
Date: Mon, 1 Apr 2024 15:26:37 -0700 [thread overview]
Message-ID: <Zgs0nRjuLz9BaJQb@boqun-archlinux> (raw)
In-Reply-To: <20240401212303.537355-2-ojeda@kernel.org>
On Mon, Apr 01, 2024 at 11:23:01PM +0200, Miguel Ojeda wrote:
> 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: https://github.com/rust-lang/rust-clippy/pull/10903 [1]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Regards,
Boqun
> ---
> rust/kernel/sync.rs | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/rust/kernel/sync.rs b/rust/kernel/sync.rs
> index c983f63fd56e..0ab20975a3b5 100644
> --- a/rust/kernel/sync.rs
> +++ b/rust/kernel/sync.rs
> @@ -37,6 +37,12 @@ pub(crate) fn as_ptr(&self) -> *mut bindings::lock_class_key {
> }
> }
>
> +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]
> --
> 2.44.0
>
next prev parent reply other threads:[~2024-04-01 22:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-01 21:23 [PATCH 0/3] Rust 1.78.0 upgrade Miguel Ojeda
2024-04-01 21:23 ` [PATCH 1/3] rust: sync: implement `Default` for `LockClassKey` Miguel Ojeda
2024-04-01 22:26 ` Boqun Feng [this message]
2024-04-02 9:46 ` Alice Ryhl
2024-04-02 23:12 ` Benno Lossin
2024-04-01 21:23 ` [PATCH 2/3] rust: kernel: remove redundant imports Miguel Ojeda
2024-04-02 9:48 ` Alice Ryhl
2024-04-01 21:23 ` [PATCH 3/3] rust: upgrade to Rust 1.78.0 Miguel Ojeda
2024-04-01 21:52 ` Miguel Ojeda
2024-04-04 12:41 ` Alice Ryhl
2024-05-05 22:33 ` [PATCH 0/3] Rust 1.78.0 upgrade Miguel Ojeda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zgs0nRjuLz9BaJQb@boqun-archlinux \
--to=boqun.feng@gmail.com \
--cc=a.hindborg@samsung.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=patches@lists.linux.dev \
--cc=rust-for-linux@vger.kernel.org \
--cc=wedsonaf@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).