Skip to content

Fixed a core crate compilation failure when enabling the optimize_for_size feature on some targets #143820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions library/core/src/fmt/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ macro_rules! impl_Display {
}
#[cfg(feature = "optimize_for_size")]
{
offset = _inner_slow_integer_to_str(self.unsigned_abs().$conv_fn(), &mut buf.buf);
offset = ${concat(_inner_slow_integer_to_str, $gen_name)}(self.unsigned_abs().$conv_fn(), &mut buf.buf);
}
// Only difference between signed and unsigned are these 4 lines.
if self < 0 {
Expand Down Expand Up @@ -401,7 +401,7 @@ macro_rules! impl_Display {
}
#[cfg(feature = "optimize_for_size")]
{
offset = _inner_slow_integer_to_str(self.$conv_fn(), &mut buf.buf);
offset = ${concat(_inner_slow_integer_to_str, $gen_name)}(self.$conv_fn(), &mut buf.buf);
}
// SAFETY: Starting from `offset`, all elements of the slice have been set.
unsafe { slice_buffer_to_str(&buf.buf, offset) }
Expand All @@ -412,7 +412,7 @@ macro_rules! impl_Display {
)*

#[cfg(feature = "optimize_for_size")]
fn _inner_slow_integer_to_str(mut n: $u, buf: &mut [MaybeUninit::<u8>]) -> usize {
fn ${concat(_inner_slow_integer_to_str, $gen_name)}(mut n: $u, buf: &mut [MaybeUninit::<u8>]) -> usize {
let mut curr = buf.len();

// SAFETY: To show that it's OK to copy into `buf_ptr`, notice that at the beginning
Expand All @@ -437,7 +437,7 @@ macro_rules! impl_Display {
const MAX_DEC_N: usize = $u::MAX.ilog(10) as usize + 1;
let mut buf = [MaybeUninit::<u8>::uninit(); MAX_DEC_N];

let offset = _inner_slow_integer_to_str(n, &mut buf);
let offset = ${concat(_inner_slow_integer_to_str, $gen_name)}(n, &mut buf);
// SAFETY: Starting from `offset`, all elements of the slice have been set.
let buf_slice = unsafe { slice_buffer_to_str(&buf, offset) };
f.pad_integral(is_nonnegative, "", buf_slice)
Expand Down
1 change: 1 addition & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
#![feature(lang_items)]
#![feature(link_llvm_intrinsics)]
#![feature(macro_metavar_expr)]
#![feature(macro_metavar_expr_concat)]
#![feature(marker_trait_attr)]
#![feature(min_specialization)]
#![feature(multiple_supertrait_upcastable)]
Expand Down
Loading