From: Trevor Gross <tmgross@umich.edu>
To: Miguel Ojeda <ojeda@kernel.org>
Cc: "Wedson Almeida Filho" <wedsonaf@gmail.com>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Alice Ryhl" <aliceryhl@google.com>,
"Andreas Hindborg" <a.hindborg@samsung.com>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@lists.linux.dev
Subject: Re: [PATCH 2/2] rust: enable `no_mangle_with_rust_abi` Clippy lint
Date: Wed, 2 Aug 2023 03:49:43 -0400 [thread overview]
Message-ID: <CALNs47sn5GT9_VKn-SGb+STFwpbUipoNyU_+ZbpDwzLXUknUUQ@mail.gmail.com> (raw)
In-Reply-To: <20230729220317.416771-2-ojeda@kernel.org>
On Sat, Jul 29, 2023 at 6:05 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> Introduced in Rust 1.69.0 [1], this lint prevents forgetting to set
> the C ABI when using `#[no_mangle]` (or thinking it is implied).
>
> For instance, it would have prevented the issue [2] fixed by commit
> c682e4c37d2b ("rust: kernel: Mark rust_fmt_argument as extern "C"").
>
> error: `#[no_mangle]` set on a function with the default (`Rust`) ABI
> --> rust/kernel/print.rs:21:1
> |
> 21 | / unsafe fn rust_fmt_argument(
> 22 | | buf: *mut c_char,
> 23 | | end: *mut c_char,
> 24 | | ptr: *const c_void,
> 25 | | ) -> *mut c_char {
> | |________________^
> |
> = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#no_mangle_with_rust_abi
> = note: requested on the command line with `-D clippy::no-mangle-with-rust-abi`
> help: set an ABI
> |
> 21 | unsafe extern "C" fn rust_fmt_argument(
> | ++++++++++
> help: or explicitly set the default
> |
> 21 | unsafe extern "Rust" fn rust_fmt_argument(
> | +++++++++++++
>
> Thus enable it.
>
> In rare cases, we may need to use the Rust ABI even with `#[no_mangle]`
> (e.g. one case, before 1.71.0, would have been the `__rust_*`
> functions). In those cases, we would need to `#[allow(...)]` the lint,
> since using `extern "Rust"` explicitly (as the compiler suggests)
> currently gets overwritten by `rustfmt` [3].
>
> Link: https://github.com/rust-lang/rust-clippy/issues/10347 [1]
> Link: https://github.com/Rust-for-Linux/linux/pull/967 [2]
> Link: https://github.com/rust-lang/rustfmt/issues/5701 [3]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> [...]
Reviewed-by: Trevor Gross <tmgross@umich.edu>
next prev parent reply other threads:[~2023-08-02 7:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-29 22:03 [PATCH 1/2] rust: upgrade to Rust 1.71.0 Miguel Ojeda
2023-07-29 22:03 ` [PATCH 2/2] rust: enable `no_mangle_with_rust_abi` Clippy lint Miguel Ojeda
2023-07-30 15:04 ` Martin Rodriguez Reboredo
2023-08-02 7:49 ` Trevor Gross [this message]
2023-08-02 18:26 ` Gary Guo
2023-07-29 23:25 ` [PATCH 1/2] rust: upgrade to Rust 1.71.0 kernel test robot
2023-07-30 15:04 ` Martin Rodriguez Reboredo
2023-08-02 7:43 ` Trevor Gross
2023-08-04 15:22 ` Miguel Ojeda
2023-08-14 22:40 ` 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=CALNs47sn5GT9_VKn-SGb+STFwpbUipoNyU_+ZbpDwzLXUknUUQ@mail.gmail.com \
--to=tmgross@umich.edu \
--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=boqun.feng@gmail.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).