Rust for Linux List
 help / color / mirror / Atom feed
From: Miguel Ojeda <ojeda@kernel.org>
To: Miguel Ojeda <ojeda@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nicolas Schier <nsc@kernel.org>
Cc: "Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org,
	"Joshua Liebow-Feeser" <joshlf@google.com>,
	"Jack Wrenn" <jswrenn@google.com>
Subject: [PATCH v2 10/19] rust: zerocopy: remove float `Display` support
Date: Mon,  8 Jun 2026 16:14:29 +0200	[thread overview]
Message-ID: <20260608141439.182634-11-ojeda@kernel.org> (raw)
In-Reply-To: <20260608141439.182634-1-ojeda@kernel.org>

The kernel builds `core` with the `no_fp_fmt_parse` `--cfg`, which means
we do not have support for formatting floating point primitives. However,
`zerocopy` expects those implementations to exist:

    error[E0277]: `f32` doesn't implement `core::fmt::Display`
       --> rust/zerocopy/src/byteorder.rs:172:29
        |
    172 |                   $trait::fmt(&self.get(), f)
        |                   ----------- ^^^^^^^^^^^ the trait `core::fmt::Display` is not implemented for `f32`
        |                   |
        |                   required by a bound introduced by this call
    ...
    907 | / define_type!(
    908 | |     An,
    909 | |     "A 32-bit floating point number",
    910 | |     F32,
    ...   |
    922 | |     []
    923 | | );
        | |_- in this macro invocation
        |
        = help: the following other types implement trait `core::fmt::Display`:
                  i128
                  i16
                  i32
                  i64
                  i8
                  isize
                  u128
                  u16
                and 4 others
        = note: this error originates in the macro `impl_fmt_trait` which comes from the expansion of the macro `define_type` (in Nightly builds, run with -Z macro-backtrace for more info)

Thus work around it by skipping those implementations in `zerocopy`.

Ideally, `zerocopy` would have the equivalent of `no_fp_fmt_parse`;
and, indeed, upstream just added it [1] after I filed an issue [2]
about it as requested. We can try it in a future update of our
vendored copy.

Cc: Joshua Liebow-Feeser <joshlf@google.com>
Cc: Jack Wrenn <jswrenn@google.com>
Link: https://github.com/google/zerocopy/pull/3429 [1]
Link: https://github.com/google/zerocopy/issues/3426 [2]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
 rust/zerocopy/src/byteorder.rs | 1 -
 1 file changed, 1 deletion(-)

diff --git a/rust/zerocopy/src/byteorder.rs b/rust/zerocopy/src/byteorder.rs
index 36ca4c0c88b0..8f70048f1eb0 100644
--- a/rust/zerocopy/src/byteorder.rs
+++ b/rust/zerocopy/src/byteorder.rs
@@ -177,7 +177,6 @@ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
 
 macro_rules! impl_fmt_traits {
     ($name:ident, $native:ident, "floating point number") => {
-        impl_fmt_trait!($name, $native, Display);
     };
     ($name:ident, $native:ident, "unsigned integer") => {
         impl_fmt_traits!($name, $native, @all_types);
-- 
2.54.0


  parent reply	other threads:[~2026-06-08 14:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-08 14:14 [PATCH v2 00/19] `zerocopy` support Miguel Ojeda
2026-06-08 14:14 ` [PATCH v2 01/19] scripts: generate_rust_analyzer: support passing env vars Miguel Ojeda
2026-06-08 14:14 ` [PATCH v2 02/19] rust: kbuild: show the right `quiet_cmd_rustc_procmacrolibrary` Miguel Ojeda
2026-06-08 14:14 ` [PATCH v2 03/19] rust: kbuild: remove unused variable Miguel Ojeda
2026-06-08 14:14 ` [PATCH v2 04/19] rust: kbuild: define `procmacro-name` function Miguel Ojeda
2026-06-08 14:14 ` [PATCH v2 05/19] rust: kbuild: define `procmacro-extension` variable Miguel Ojeda
2026-06-08 14:14 ` [PATCH v2 06/19] rust: kbuild: support per-target environment variables Miguel Ojeda
2026-06-08 14:14 ` [PATCH v2 07/19] rust: kbuild: support `skip_clippy` for `rustc_procmacro` Miguel Ojeda
2026-06-08 14:14 ` [PATCH v2 08/19] rust: zerocopy: import crate Miguel Ojeda
2026-06-08 14:14 ` [PATCH v2 09/19] rust: zerocopy: add SPDX License Identifiers Miguel Ojeda
2026-06-08 14:14 ` Miguel Ojeda [this message]
2026-06-08 14:14 ` [PATCH v2 11/19] rust: zerocopy: add `README.md` Miguel Ojeda
2026-06-08 14:14 ` [PATCH v2 12/19] rust: zerocopy: enable support in kbuild Miguel Ojeda
2026-06-08 14:14 ` [PATCH v2 13/19] rust: zerocopy-derive: import crate Miguel Ojeda
2026-06-08 14:14 ` [PATCH v2 14/19] rust: zerocopy-derive: add SPDX License Identifiers Miguel Ojeda
2026-06-08 14:14 ` [PATCH v2 15/19] rust: zerocopy-derive: avoid generating non-ASCII identifiers Miguel Ojeda
2026-06-08 14:14 ` [PATCH v2 16/19] rust: zerocopy-derive: add `README.md` Miguel Ojeda
2026-06-08 14:14 ` [PATCH v2 17/19] rust: zerocopy-derive: enable support in kbuild Miguel Ojeda
2026-06-08 14:14 ` [PATCH v2 18/19] rust: prelude: add `zerocopy{,_derive}::FromBytes` Miguel Ojeda
2026-06-08 14:14 ` [PATCH v2 19/19] gpu: nova-core: firmware: parse `FalconUCodeDescV2` via `zerocopy` Miguel Ojeda
2026-06-08 14:32   ` Gary Guo
2026-06-08 14:36     ` Danilo Krummrich
2026-06-08 15:30       ` 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=20260608141439.182634-11-ojeda@kernel.org \
    --to=ojeda@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=joshlf@google.com \
    --cc=jswrenn@google.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /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