Skip to content

Commit

Permalink
Auto merge of #128056 - jieyouxu:rollup-zb1y27e, r=jieyouxu
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Jul 22, 2024
2 parents ae7b1c1 + c4c0ca4 commit aee3dc4
Show file tree
Hide file tree
Showing 58 changed files with 2,736 additions and 604 deletions.
75 changes: 75 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2598,12 +2598,76 @@ dependencies = [
"windows-sys 0.48.0",
]

[[package]]
name = "num"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23"
dependencies = [
"num-bigint",
"num-complex",
"num-integer",
"num-iter",
"num-rational",
"num-traits",
]

[[package]]
name = "num-bigint"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9"
dependencies = [
"num-integer",
"num-traits",
]

[[package]]
name = "num-complex"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
dependencies = [
"num-traits",
]

[[package]]
name = "num-conv"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"

[[package]]
name = "num-integer"
version = "0.1.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
dependencies = [
"num-traits",
]

[[package]]
name = "num-iter"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]

[[package]]
name = "num-rational"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
dependencies = [
"num-bigint",
"num-integer",
"num-traits",
]

[[package]]
name = "num-traits"
version = "0.2.19"
Expand Down Expand Up @@ -5630,6 +5694,17 @@ dependencies = [
"std",
]

[[package]]
name = "test-float-parse"
version = "0.1.0"
dependencies = [
"indicatif",
"num",
"rand",
"rand_chacha",
"rayon",
]

[[package]]
name = "textwrap"
version = "0.16.1"
Expand Down
13 changes: 13 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"compiler/rustc",
"library/std",
"library/sysroot",
"src/etc/test-float-parse",
"src/rustdoc-json-types",
"src/tools/build_helper",
"src/tools/cargotest",
Expand Down Expand Up @@ -109,6 +110,18 @@ strip = true
debug = 0
strip = true

# Bigint libraries are slow without optimization, speed up testing
[profile.dev.package.test-float-parse]
opt-level = 3

# Speed up the binary as much as possible
[profile.release.package.test-float-parse]
opt-level = 3
codegen-units = 1
# FIXME: LTO cannot be enabled for binaries in a workspace
# <https://github.com/rust-lang/cargo/issues/9330>
# lto = true

[patch.crates-io]
# See comments in `library/rustc-std-workspace-core/README.md` for what's going on
# here
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ For more docs on how to build and test see [build_system/usage.txt](build_system
|FreeBSD|[^no-rustup]||||
|AIX|[^xcoff]|N/A|N/A|[^xcoff]|
|Other unixes|||||
|macOS||[^no-rustup]|N/A|N/A|
|macOS|||N/A|N/A|
|Windows|[^no-rustup]||N/A|N/A|

✅: Fully supported and tested
Expand Down
83 changes: 81 additions & 2 deletions library/alloc/src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ impl<T> Box<[T]> {
}

/// Constructs a new boxed slice with uninitialized contents. Returns an error if
/// the allocation fails
/// the allocation fails.
///
/// # Examples
///
Expand Down Expand Up @@ -739,7 +739,7 @@ impl<T> Box<[T]> {
}

/// Constructs a new boxed slice with uninitialized contents, with the memory
/// being filled with `0` bytes. Returns an error if the allocation fails
/// being filled with `0` bytes. Returns an error if the allocation fails.
///
/// See [`MaybeUninit::zeroed`][zeroed] for examples of correct and incorrect usage
/// of this method.
Expand Down Expand Up @@ -831,6 +831,85 @@ impl<T, A: Allocator> Box<[T], A> {
pub fn new_zeroed_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit<T>], A> {
unsafe { RawVec::with_capacity_zeroed_in(len, alloc).into_box(len) }
}

/// Constructs a new boxed slice with uninitialized contents in the provided allocator. Returns an error if
/// the allocation fails.
///
/// # Examples
///
/// ```
/// #![feature(allocator_api, new_uninit)]
///
/// use std::alloc::System;
///
/// let mut values = Box::<[u32], _>::try_new_uninit_slice_in(3, System)?;
/// let values = unsafe {
/// // Deferred initialization:
/// values[0].as_mut_ptr().write(1);
/// values[1].as_mut_ptr().write(2);
/// values[2].as_mut_ptr().write(3);
/// values.assume_init()
/// };
///
/// assert_eq!(*values, [1, 2, 3]);
/// # Ok::<(), std::alloc::AllocError>(())
/// ```
#[unstable(feature = "allocator_api", issue = "32838")]
#[inline]
pub fn try_new_uninit_slice_in(
len: usize,
alloc: A,
) -> Result<Box<[mem::MaybeUninit<T>], A>, AllocError> {
let ptr = if T::IS_ZST || len == 0 {
NonNull::dangling()
} else {
let layout = match Layout::array::<mem::MaybeUninit<T>>(len) {
Ok(l) => l,
Err(_) => return Err(AllocError),
};
alloc.allocate(layout)?.cast()
};
unsafe { Ok(RawVec::from_raw_parts_in(ptr.as_ptr(), len, alloc).into_box(len)) }
}

/// Constructs a new boxed slice with uninitialized contents in the provided allocator, with the memory
/// being filled with `0` bytes. Returns an error if the allocation fails.
///
/// See [`MaybeUninit::zeroed`][zeroed] for examples of correct and incorrect usage
/// of this method.
///
/// # Examples
///
/// ```
/// #![feature(allocator_api, new_uninit)]
///
/// use std::alloc::System;
///
/// let values = Box::<[u32], _>::try_new_zeroed_slice_in(3, System)?;
/// let values = unsafe { values.assume_init() };
///
/// assert_eq!(*values, [0, 0, 0]);
/// # Ok::<(), std::alloc::AllocError>(())
/// ```
///
/// [zeroed]: mem::MaybeUninit::zeroed
#[unstable(feature = "allocator_api", issue = "32838")]
#[inline]
pub fn try_new_zeroed_slice_in(
len: usize,
alloc: A,
) -> Result<Box<[mem::MaybeUninit<T>], A>, AllocError> {
let ptr = if T::IS_ZST || len == 0 {
NonNull::dangling()
} else {
let layout = match Layout::array::<mem::MaybeUninit<T>>(len) {
Ok(l) => l,
Err(_) => return Err(AllocError),
};
alloc.allocate_zeroed(layout)?.cast()
};
unsafe { Ok(RawVec::from_raw_parts_in(ptr.as_ptr(), len, alloc).into_box(len)) }
}
}

impl<T, A: Allocator> Box<mem::MaybeUninit<T>, A> {
Expand Down
1 change: 1 addition & 0 deletions library/std/src/os/horizon/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Definitions for Horizon OS

#![forbid(unsafe_op_in_unsafe_fn)]
#![stable(feature = "raw_ext", since = "1.1.0")]

pub mod fs;
Expand Down
1 change: 1 addition & 0 deletions library/std/src/os/horizon/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub type time_t = libc::time_t;
#[repr(C)]
#[derive(Clone)]
#[stable(feature = "raw_ext", since = "1.1.0")]
#[allow(dead_code)] // This exists for parity with other `raw` modules, but isn't actually used.
pub struct stat {
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_dev: dev_t,
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/pal/unix/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ cfg_if::cfg_if! {
))] {
#[inline]
unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 {
libc::memalign(layout.align(), layout.size()) as *mut u8
unsafe { libc::memalign(layout.align(), layout.size()) as *mut u8 }
}
} else {
#[inline]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::fmt;
use crate::io;
use crate::num::NonZero;
use crate::sys::pal::unix::unsupported::*;
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/mk/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ check-aux:
$(Q)$(BOOTSTRAP) test --stage 2 \
src/tools/cargo \
src/tools/cargotest \
src/etc/test-float-parse \
$(BOOTSTRAP_ARGS)
# Run standard library tests in Miri.
$(Q)BOOTSTRAP_SKIP_TARGET_SANITY=1 \
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/src/core/build_steps/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ tool_check_step!(CargoMiri, "src/tools/miri/cargo-miri", SourceType::InTree);
tool_check_step!(Rls, "src/tools/rls", SourceType::InTree);
tool_check_step!(Rustfmt, "src/tools/rustfmt", SourceType::InTree);
tool_check_step!(MiroptTestTools, "src/tools/miropt-test-tools", SourceType::InTree);
tool_check_step!(TestFloatParse, "src/etc/test-float-parse", SourceType::InTree);

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

Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/src/core/build_steps/clippy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,4 +326,5 @@ lint_any!(
Rustfmt, "src/tools/rustfmt", "rustfmt";
RustInstaller, "src/tools/rust-installer", "rust-installer";
Tidy, "src/tools/tidy", "tidy";
TestFloatParse, "src/etc/test-float-parse", "test-float-parse";
);
77 changes: 77 additions & 0 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3505,3 +3505,80 @@ impl Step for CodegenGCC {
cargo.into_cmd().run(builder);
}
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TestFloatParse {
path: PathBuf,
host: TargetSelection,
}

impl Step for TestFloatParse {
type Output = ();
const ONLY_HOSTS: bool = true;
const DEFAULT: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/etc/test-float-parse")
}

fn make_run(run: RunConfig<'_>) {
for path in run.paths {
let path = path.assert_single_path().path.clone();
run.builder.ensure(Self { path, host: run.target });
}
}

fn run(self, builder: &Builder<'_>) {
let bootstrap_host = builder.config.build;
let compiler = builder.compiler(0, bootstrap_host);
let path = self.path.to_str().unwrap();
let crate_name = self.path.components().last().unwrap().as_os_str().to_str().unwrap();

builder.ensure(compile::Std::new(compiler, self.host));

// Run any unit tests in the crate
let cargo_test = tool::prepare_tool_cargo(
builder,
compiler,
Mode::ToolStd,
bootstrap_host,
"test",
path,
SourceType::InTree,
&[],
);

run_cargo_test(
cargo_test,
&[],
&[],
crate_name,
crate_name,
compiler,
bootstrap_host,
builder,
);

// Run the actual parse tests.
let mut cargo_run = tool::prepare_tool_cargo(
builder,
compiler,
Mode::ToolStd,
bootstrap_host,
"run",
path,
SourceType::InTree,
&[],
);

cargo_run.arg("--");
if builder.config.args().is_empty() {
// By default, exclude tests that take longer than ~1m.
cargo_run.arg("--skip-huge");
} else {
cargo_run.args(builder.config.args());
}

cargo_run.into_cmd().run(builder);
}
}
3 changes: 3 additions & 0 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ impl<'a> Builder<'a> {
clippy::Rustdoc,
clippy::Rustfmt,
clippy::RustInstaller,
clippy::TestFloatParse,
clippy::Tidy,
),
Kind::Check | Kind::Fix => describe!(
Expand All @@ -840,6 +841,7 @@ impl<'a> Builder<'a> {
check::Rls,
check::Rustfmt,
check::RustAnalyzer,
check::TestFloatParse,
check::Bootstrap,
),
Kind::Test => describe!(
Expand Down Expand Up @@ -901,6 +903,7 @@ impl<'a> Builder<'a> {
test::RustdocJson,
test::HtmlCheck,
test::RustInstaller,
test::TestFloatParse,
// Run bootstrap close to the end as it's unlikely to fail
test::Bootstrap,
// Run run-make last, since these won't pass without make on Windows
Expand Down
Loading

0 comments on commit aee3dc4

Please sign in to comment.