- Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
With this code,
#![no_std] #![no_main] #[panic_handler] fn panic(_panic: &core::panic::PanicInfo<'_>) -> ! { loop {} }
This builds fine for thumbv6m-none-eabi
target:
cargo build --target thumbv6m-none-eabi -Z build-std=core --release
However, adding optimize_for_size
to build-std-features
as follows causes the build to fail
cargo build --target thumbv6m-none-eabi -Z build-std=core -Z build-std-features=optimize_for_size --release
with this error
Compiling core v0.0.0 (/home/nazo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core) error[E0428]: the name `_inner_slow_integer_to_str` is defined multiple times --> /home/nazo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/num.rs:415:9 | 415 | fn _inner_slow_integer_to_str(mut n: $u, buf: &mut [MaybeUninit::<u8>]) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | `_inner_slow_integer_to_str` redefined here | previous definition of the value `_inner_slow_integer_to_str` here ... 643 | / impl_Display!( 644 | | i8, u8, 645 | | i16, u16, 646 | | i32, u32, 647 | | isize, usize, 648 | | ; as u32 via to_u32 named fmt_u32); | |__________________________________________- in this macro invocation | = note: `_inner_slow_integer_to_str` must be defined only once in the value namespace of this module = note: this error originates in the macro `impl_Display` (in Nightly builds, run with -Z macro-backtrace for more info)
I am not familiar with the Rust code base, but I think the cause is that #142098 resulted in _inner_slow_integer_to_str
being defined multiple times.
In fact, this compiles without error in nightly-2025-07-08.
Meta
rustc --version --verbose
:
rustc 1.90.0-nightly (2a023bf80 2025-07-10) binary: rustc commit-hash: 2a023bf80a6fbd6a06d5460a34eb247b986286ed commit-date: 2025-07-10 host: x86_64-unknown-linux-gnu release: 1.90.0-nightly LLVM version: 20.1.7
Backtrace
Compiling core v0.0.0 (/home/nazo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core) error[E0428]: the name `_inner_slow_integer_to_str` is defined multiple times --> /home/nazo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/num.rs:415:9 | 415 | fn _inner_slow_integer_to_str(mut n: $u, buf: &mut [MaybeUninit::<u8>]) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | `_inner_slow_integer_to_str` redefined here | previous definition of the value `_inner_slow_integer_to_str` here ... 643 | / impl_Display!( 644 | | i8, u8, 645 | | i16, u16, 646 | | i32, u32, 647 | | isize, usize, 648 | | ; as u32 via to_u32 named fmt_u32); | |__________________________________________- in this macro invocation | = note: `_inner_slow_integer_to_str` must be defined only once in the value namespace of this module = note: this error originates in the macro `impl_Display` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> /home/nazo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/num.rs:361:57 | 361 | offset = _inner_slow_integer_to_str(self.unsigned_abs().$conv_fn(), &mut buf.buf); | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `u64` | | | arguments to this function are incorrect ... 649 | / impl_Display!( 650 | | i64, u64, 651 | | ; as u64 via to_u64 named fmt_u64); | |__________________________________________- in this macro invocation | note: function defined here --> /home/nazo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/num.rs:415:12 | 415 | fn _inner_slow_integer_to_str(mut n: $u, buf: &mut [MaybeUninit::<u8>]) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ --------- ... 643 | / impl_Display!( 644 | | i8, u8, 645 | | i16, u16, 646 | | i32, u32, 647 | | isize, usize, 648 | | ; as u32 via to_u32 named fmt_u32); | |__________________________________________- in this macro invocation = note: this error originates in the macro `impl_Display` (in Nightly builds, run with -Z macro-backtrace for more info) help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit | 361 | offset = _inner_slow_integer_to_str(self.unsigned_abs().$conv_fn().try_into().unwrap(), &mut buf.buf); | ++++++++++++++++++++ error[E0308]: mismatched types --> /home/nazo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/num.rs:404:57 | 404 | offset = _inner_slow_integer_to_str(self.$conv_fn(), &mut buf.buf); | -------------------------- ^^^^^^^^^^^^^^^ expected `u32`, found `u64` | | | arguments to this function are incorrect ... 649 | / impl_Display!( 650 | | i64, u64, 651 | | ; as u64 via to_u64 named fmt_u64); | |__________________________________________- in this macro invocation | note: function defined here --> /home/nazo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/num.rs:415:12 | 415 | fn _inner_slow_integer_to_str(mut n: $u, buf: &mut [MaybeUninit::<u8>]) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ --------- ... 643 | / impl_Display!( 644 | | i8, u8, 645 | | i16, u16, 646 | | i32, u32, 647 | | isize, usize, 648 | | ; as u32 via to_u32 named fmt_u32); | |__________________________________________- in this macro invocation = note: this error originates in the macro `impl_Display` (in Nightly builds, run with -Z macro-backtrace for more info) help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit | 404 | offset = _inner_slow_integer_to_str(self.$conv_fn().try_into().unwrap(), &mut buf.buf); | ++++++++++++++++++++ error[E0308]: mismatched types --> /home/nazo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/num.rs:440:53 | 440 | let offset = _inner_slow_integer_to_str(n, &mut buf); | -------------------------- ^ expected `u32`, found `u64` | | | arguments to this function are incorrect ... 649 | / impl_Display!( 650 | | i64, u64, 651 | | ; as u64 via to_u64 named fmt_u64); | |__________________________________________- in this macro invocation | note: function defined here --> /home/nazo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/num.rs:415:12 | 415 | fn _inner_slow_integer_to_str(mut n: $u, buf: &mut [MaybeUninit::<u8>]) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ --------- ... 643 | / impl_Display!( 644 | | i8, u8, 645 | | i16, u16, 646 | | i32, u32, 647 | | isize, usize, 648 | | ; as u32 via to_u32 named fmt_u32); | |__________________________________________- in this macro invocation = note: this error originates in the macro `impl_Display` (in Nightly builds, run with -Z macro-backtrace for more info) help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit | 440 | let offset = _inner_slow_integer_to_str(n.try_into().unwrap(), &mut buf); | ++++++++++++++++++++ Some errors have detailed explanations: E0308, E0428. For more information about an error, try `rustc --explain E0308`. error: could not compile `core` (lib) due to 4 previous errors
Ddystopia
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.