Skip to content

[byteorder] Add cfg no_fp_fmt_parse#3429

Merged
joshlf merged 1 commit into
google:mainfrom
eiffel-fl:francis/no_fp_fmt_parse
Jun 5, 2026
Merged

[byteorder] Add cfg no_fp_fmt_parse#3429
joshlf merged 1 commit into
google:mainfrom
eiffel-fl:francis/no_fp_fmt_parse

Conversation

@eiffel-fl

Copy link
Copy Markdown
Contributor

This cfg deactivates Debug and Display for floatting point numbers, this is particluarly useful in kernel context.
The implementation is inspired by:
rust-lang/rust@ec7292ad3c35

Fixes #3426

@codecov-commenter

codecov-commenter commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.85%. Comparing base (bc0bb77) to head (97f7f64).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3429   +/-   ##
=======================================
  Coverage   91.85%   91.85%           
=======================================
  Files          20       20           
  Lines        6093     6093           
=======================================
  Hits         5597     5597           
  Misses        496      496           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joshlf joshlf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for this! If you rebase on main, the CI errors should go away (fixed by #3430)

@joshlf joshlf enabled auto-merge June 3, 2026 20:59
auto-merge was automatically disabled June 4, 2026 14:56

Head branch was pushed to by a user without write access

@eiffel-fl eiffel-fl force-pushed the francis/no_fp_fmt_parse branch 2 times, most recently from 248cab7 to eee33ee Compare June 4, 2026 14:59
This cfg deactivates Debug and Display for floatting point numbers, this is
particluarly useful in kernel context.
The implementation is inspired by:
rust-lang/rust@ec7292ad3c35

Fixes google#3426
@eiffel-fl eiffel-fl force-pushed the francis/no_fp_fmt_parse branch from eee33ee to 97f7f64 Compare June 5, 2026 06:32
@eiffel-fl eiffel-fl requested a review from joshlf June 5, 2026 13:26
@joshlf joshlf added this pull request to the merge queue Jun 5, 2026
Merged via the queue into google:main with commit c97143c Jun 5, 2026
127 checks passed
@ojeda

ojeda commented Jun 5, 2026

Copy link
Copy Markdown

Thanks for this!

@eiffel-fl

Copy link
Copy Markdown
Contributor Author

Welcome! Thanks for the review and merge!

ojeda added a commit to Rust-for-Linux/linux that referenced this pull request Jun 9, 2026
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: google/zerocopy#3429 [1]
Link: google/zerocopy#3426 [2]
Link: https://patch.msgid.link/20260608141439.182634-11-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linux kernel: cfg(no_fp_fmt_parse)

4 participants