Skip to content

Commit aee3dc4

Browse files
committed
Auto merge of #128056 - jieyouxu:rollup-zb1y27e, r=jieyouxu
Rollup of 8 pull requests Successful merges: - #127177 (Distribute rustc_codegen_cranelift for arm64 macOS) - #127415 (Add missing try_new_uninit_slice_in and try_new_zeroed_slice_in) - #127510 (Rewrite `test-float-parse` in Rust) - #127977 (Update wasi-sdk in CI to latest release) - #127985 (Migrate `test-benches`, `c-unwind-abi-catch-panic` and `compiler-lookup-paths-2` `run-make` tests to rmake) - #127996 (Clean up warnings + `unsafe_op_in_unsafe_fn` when building std for armv6k-nintendo-3ds) - #128035 (Add test for #125837) - #128054 (mw triagebot vacation) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ae7b1c1 + c4c0ca4 commit aee3dc4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2736
-604
lines changed

Cargo.lock

+75
Original file line numberDiff line numberDiff line change
@@ -2598,12 +2598,76 @@ dependencies = [
25982598
"windows-sys 0.48.0",
25992599
]
26002600

2601+
[[package]]
2602+
name = "num"
2603+
version = "0.4.3"
2604+
source = "registry+https://github.com/rust-lang/crates.io-index"
2605+
checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23"
2606+
dependencies = [
2607+
"num-bigint",
2608+
"num-complex",
2609+
"num-integer",
2610+
"num-iter",
2611+
"num-rational",
2612+
"num-traits",
2613+
]
2614+
2615+
[[package]]
2616+
name = "num-bigint"
2617+
version = "0.4.6"
2618+
source = "registry+https://github.com/rust-lang/crates.io-index"
2619+
checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9"
2620+
dependencies = [
2621+
"num-integer",
2622+
"num-traits",
2623+
]
2624+
2625+
[[package]]
2626+
name = "num-complex"
2627+
version = "0.4.6"
2628+
source = "registry+https://github.com/rust-lang/crates.io-index"
2629+
checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
2630+
dependencies = [
2631+
"num-traits",
2632+
]
2633+
26012634
[[package]]
26022635
name = "num-conv"
26032636
version = "0.1.0"
26042637
source = "registry+https://github.com/rust-lang/crates.io-index"
26052638
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
26062639

2640+
[[package]]
2641+
name = "num-integer"
2642+
version = "0.1.46"
2643+
source = "registry+https://github.com/rust-lang/crates.io-index"
2644+
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
2645+
dependencies = [
2646+
"num-traits",
2647+
]
2648+
2649+
[[package]]
2650+
name = "num-iter"
2651+
version = "0.1.45"
2652+
source = "registry+https://github.com/rust-lang/crates.io-index"
2653+
checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf"
2654+
dependencies = [
2655+
"autocfg",
2656+
"num-integer",
2657+
"num-traits",
2658+
]
2659+
2660+
[[package]]
2661+
name = "num-rational"
2662+
version = "0.4.2"
2663+
source = "registry+https://github.com/rust-lang/crates.io-index"
2664+
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
2665+
dependencies = [
2666+
"num-bigint",
2667+
"num-integer",
2668+
"num-traits",
2669+
]
2670+
26072671
[[package]]
26082672
name = "num-traits"
26092673
version = "0.2.19"
@@ -5630,6 +5694,17 @@ dependencies = [
56305694
"std",
56315695
]
56325696

5697+
[[package]]
5698+
name = "test-float-parse"
5699+
version = "0.1.0"
5700+
dependencies = [
5701+
"indicatif",
5702+
"num",
5703+
"rand",
5704+
"rand_chacha",
5705+
"rayon",
5706+
]
5707+
56335708
[[package]]
56345709
name = "textwrap"
56355710
version = "0.16.1"

Cargo.toml

+13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ members = [
44
"compiler/rustc",
55
"library/std",
66
"library/sysroot",
7+
"src/etc/test-float-parse",
78
"src/rustdoc-json-types",
89
"src/tools/build_helper",
910
"src/tools/cargotest",
@@ -109,6 +110,18 @@ strip = true
109110
debug = 0
110111
strip = true
111112

113+
# Bigint libraries are slow without optimization, speed up testing
114+
[profile.dev.package.test-float-parse]
115+
opt-level = 3
116+
117+
# Speed up the binary as much as possible
118+
[profile.release.package.test-float-parse]
119+
opt-level = 3
120+
codegen-units = 1
121+
# FIXME: LTO cannot be enabled for binaries in a workspace
122+
# <https://github.com/rust-lang/cargo/issues/9330>
123+
# lto = true
124+
112125
[patch.crates-io]
113126
# See comments in `library/rustc-std-workspace-core/README.md` for what's going on
114127
# here

compiler/rustc_codegen_cranelift/Readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ For more docs on how to build and test see [build_system/usage.txt](build_system
7070
|FreeBSD|[^no-rustup]||||
7171
|AIX|[^xcoff]|N/A|N/A|[^xcoff]|
7272
|Other unixes|||||
73-
|macOS||[^no-rustup]|N/A|N/A|
73+
|macOS|||N/A|N/A|
7474
|Windows|[^no-rustup]||N/A|N/A|
7575

7676
✅: Fully supported and tested

library/alloc/src/boxed.rs

+81-2
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ impl<T> Box<[T]> {
704704
}
705705

706706
/// Constructs a new boxed slice with uninitialized contents. Returns an error if
707-
/// the allocation fails
707+
/// the allocation fails.
708708
///
709709
/// # Examples
710710
///
@@ -739,7 +739,7 @@ impl<T> Box<[T]> {
739739
}
740740

741741
/// Constructs a new boxed slice with uninitialized contents, with the memory
742-
/// being filled with `0` bytes. Returns an error if the allocation fails
742+
/// being filled with `0` bytes. Returns an error if the allocation fails.
743743
///
744744
/// See [`MaybeUninit::zeroed`][zeroed] for examples of correct and incorrect usage
745745
/// of this method.
@@ -831,6 +831,85 @@ impl<T, A: Allocator> Box<[T], A> {
831831
pub fn new_zeroed_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit<T>], A> {
832832
unsafe { RawVec::with_capacity_zeroed_in(len, alloc).into_box(len) }
833833
}
834+
835+
/// Constructs a new boxed slice with uninitialized contents in the provided allocator. Returns an error if
836+
/// the allocation fails.
837+
///
838+
/// # Examples
839+
///
840+
/// ```
841+
/// #![feature(allocator_api, new_uninit)]
842+
///
843+
/// use std::alloc::System;
844+
///
845+
/// let mut values = Box::<[u32], _>::try_new_uninit_slice_in(3, System)?;
846+
/// let values = unsafe {
847+
/// // Deferred initialization:
848+
/// values[0].as_mut_ptr().write(1);
849+
/// values[1].as_mut_ptr().write(2);
850+
/// values[2].as_mut_ptr().write(3);
851+
/// values.assume_init()
852+
/// };
853+
///
854+
/// assert_eq!(*values, [1, 2, 3]);
855+
/// # Ok::<(), std::alloc::AllocError>(())
856+
/// ```
857+
#[unstable(feature = "allocator_api", issue = "32838")]
858+
#[inline]
859+
pub fn try_new_uninit_slice_in(
860+
len: usize,
861+
alloc: A,
862+
) -> Result<Box<[mem::MaybeUninit<T>], A>, AllocError> {
863+
let ptr = if T::IS_ZST || len == 0 {
864+
NonNull::dangling()
865+
} else {
866+
let layout = match Layout::array::<mem::MaybeUninit<T>>(len) {
867+
Ok(l) => l,
868+
Err(_) => return Err(AllocError),
869+
};
870+
alloc.allocate(layout)?.cast()
871+
};
872+
unsafe { Ok(RawVec::from_raw_parts_in(ptr.as_ptr(), len, alloc).into_box(len)) }
873+
}
874+
875+
/// Constructs a new boxed slice with uninitialized contents in the provided allocator, with the memory
876+
/// being filled with `0` bytes. Returns an error if the allocation fails.
877+
///
878+
/// See [`MaybeUninit::zeroed`][zeroed] for examples of correct and incorrect usage
879+
/// of this method.
880+
///
881+
/// # Examples
882+
///
883+
/// ```
884+
/// #![feature(allocator_api, new_uninit)]
885+
///
886+
/// use std::alloc::System;
887+
///
888+
/// let values = Box::<[u32], _>::try_new_zeroed_slice_in(3, System)?;
889+
/// let values = unsafe { values.assume_init() };
890+
///
891+
/// assert_eq!(*values, [0, 0, 0]);
892+
/// # Ok::<(), std::alloc::AllocError>(())
893+
/// ```
894+
///
895+
/// [zeroed]: mem::MaybeUninit::zeroed
896+
#[unstable(feature = "allocator_api", issue = "32838")]
897+
#[inline]
898+
pub fn try_new_zeroed_slice_in(
899+
len: usize,
900+
alloc: A,
901+
) -> Result<Box<[mem::MaybeUninit<T>], A>, AllocError> {
902+
let ptr = if T::IS_ZST || len == 0 {
903+
NonNull::dangling()
904+
} else {
905+
let layout = match Layout::array::<mem::MaybeUninit<T>>(len) {
906+
Ok(l) => l,
907+
Err(_) => return Err(AllocError),
908+
};
909+
alloc.allocate_zeroed(layout)?.cast()
910+
};
911+
unsafe { Ok(RawVec::from_raw_parts_in(ptr.as_ptr(), len, alloc).into_box(len)) }
912+
}
834913
}
835914

836915
impl<T, A: Allocator> Box<mem::MaybeUninit<T>, A> {

library/std/src/os/horizon/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Definitions for Horizon OS
22
3+
#![forbid(unsafe_op_in_unsafe_fn)]
34
#![stable(feature = "raw_ext", since = "1.1.0")]
45

56
pub mod fs;

library/std/src/os/horizon/raw.rs

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub type time_t = libc::time_t;
3838
#[repr(C)]
3939
#[derive(Clone)]
4040
#[stable(feature = "raw_ext", since = "1.1.0")]
41+
#[allow(dead_code)] // This exists for parity with other `raw` modules, but isn't actually used.
4142
pub struct stat {
4243
#[stable(feature = "raw_ext", since = "1.1.0")]
4344
pub st_dev: dev_t,

library/std/src/sys/pal/unix/alloc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ cfg_if::cfg_if! {
6767
))] {
6868
#[inline]
6969
unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 {
70-
libc::memalign(layout.align(), layout.size()) as *mut u8
70+
unsafe { libc::memalign(layout.align(), layout.size()) as *mut u8 }
7171
}
7272
} else {
7373
#[inline]

library/std/src/sys/pal/unix/process/process_unsupported.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::fmt;
21
use crate::io;
32
use crate::num::NonZero;
43
use crate::sys::pal::unix::unsupported::*;

src/bootstrap/mk/Makefile.in

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ check-aux:
5151
$(Q)$(BOOTSTRAP) test --stage 2 \
5252
src/tools/cargo \
5353
src/tools/cargotest \
54+
src/etc/test-float-parse \
5455
$(BOOTSTRAP_ARGS)
5556
# Run standard library tests in Miri.
5657
$(Q)BOOTSTRAP_SKIP_TARGET_SANITY=1 \

src/bootstrap/src/core/build_steps/check.rs

+1
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ tool_check_step!(CargoMiri, "src/tools/miri/cargo-miri", SourceType::InTree);
466466
tool_check_step!(Rls, "src/tools/rls", SourceType::InTree);
467467
tool_check_step!(Rustfmt, "src/tools/rustfmt", SourceType::InTree);
468468
tool_check_step!(MiroptTestTools, "src/tools/miropt-test-tools", SourceType::InTree);
469+
tool_check_step!(TestFloatParse, "src/etc/test-float-parse", SourceType::InTree);
469470

470471
tool_check_step!(Bootstrap, "src/bootstrap", SourceType::InTree, false);
471472

src/bootstrap/src/core/build_steps/clippy.rs

+1
Original file line numberDiff line numberDiff line change
@@ -326,4 +326,5 @@ lint_any!(
326326
Rustfmt, "src/tools/rustfmt", "rustfmt";
327327
RustInstaller, "src/tools/rust-installer", "rust-installer";
328328
Tidy, "src/tools/tidy", "tidy";
329+
TestFloatParse, "src/etc/test-float-parse", "test-float-parse";
329330
);

src/bootstrap/src/core/build_steps/test.rs

+77
Original file line numberDiff line numberDiff line change
@@ -3505,3 +3505,80 @@ impl Step for CodegenGCC {
35053505
cargo.into_cmd().run(builder);
35063506
}
35073507
}
3508+
3509+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3510+
pub struct TestFloatParse {
3511+
path: PathBuf,
3512+
host: TargetSelection,
3513+
}
3514+
3515+
impl Step for TestFloatParse {
3516+
type Output = ();
3517+
const ONLY_HOSTS: bool = true;
3518+
const DEFAULT: bool = true;
3519+
3520+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
3521+
run.path("src/etc/test-float-parse")
3522+
}
3523+
3524+
fn make_run(run: RunConfig<'_>) {
3525+
for path in run.paths {
3526+
let path = path.assert_single_path().path.clone();
3527+
run.builder.ensure(Self { path, host: run.target });
3528+
}
3529+
}
3530+
3531+
fn run(self, builder: &Builder<'_>) {
3532+
let bootstrap_host = builder.config.build;
3533+
let compiler = builder.compiler(0, bootstrap_host);
3534+
let path = self.path.to_str().unwrap();
3535+
let crate_name = self.path.components().last().unwrap().as_os_str().to_str().unwrap();
3536+
3537+
builder.ensure(compile::Std::new(compiler, self.host));
3538+
3539+
// Run any unit tests in the crate
3540+
let cargo_test = tool::prepare_tool_cargo(
3541+
builder,
3542+
compiler,
3543+
Mode::ToolStd,
3544+
bootstrap_host,
3545+
"test",
3546+
path,
3547+
SourceType::InTree,
3548+
&[],
3549+
);
3550+
3551+
run_cargo_test(
3552+
cargo_test,
3553+
&[],
3554+
&[],
3555+
crate_name,
3556+
crate_name,
3557+
compiler,
3558+
bootstrap_host,
3559+
builder,
3560+
);
3561+
3562+
// Run the actual parse tests.
3563+
let mut cargo_run = tool::prepare_tool_cargo(
3564+
builder,
3565+
compiler,
3566+
Mode::ToolStd,
3567+
bootstrap_host,
3568+
"run",
3569+
path,
3570+
SourceType::InTree,
3571+
&[],
3572+
);
3573+
3574+
cargo_run.arg("--");
3575+
if builder.config.args().is_empty() {
3576+
// By default, exclude tests that take longer than ~1m.
3577+
cargo_run.arg("--skip-huge");
3578+
} else {
3579+
cargo_run.args(builder.config.args());
3580+
}
3581+
3582+
cargo_run.into_cmd().run(builder);
3583+
}
3584+
}

src/bootstrap/src/core/builder.rs

+3
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,7 @@ impl<'a> Builder<'a> {
826826
clippy::Rustdoc,
827827
clippy::Rustfmt,
828828
clippy::RustInstaller,
829+
clippy::TestFloatParse,
829830
clippy::Tidy,
830831
),
831832
Kind::Check | Kind::Fix => describe!(
@@ -840,6 +841,7 @@ impl<'a> Builder<'a> {
840841
check::Rls,
841842
check::Rustfmt,
842843
check::RustAnalyzer,
844+
check::TestFloatParse,
843845
check::Bootstrap,
844846
),
845847
Kind::Test => describe!(
@@ -901,6 +903,7 @@ impl<'a> Builder<'a> {
901903
test::RustdocJson,
902904
test::HtmlCheck,
903905
test::RustInstaller,
906+
test::TestFloatParse,
904907
// Run bootstrap close to the end as it's unlikely to fail
905908
test::Bootstrap,
906909
// Run run-make last, since these won't pass without make on Windows

0 commit comments

Comments
 (0)