Skip to content

Commit 16450f7

Browse files
author
The Miri Cronjob Bot
committed
Merge from rustc
2 parents 00b4f61 + eee5bba commit 16450f7

Some content is hidden

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

46 files changed

+1898
-275
lines changed

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> {

core/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
#![feature(const_unsafecell_get_mut)]
166166
#![feature(const_waker)]
167167
#![feature(coverage_attribute)]
168+
#![feature(do_not_recommend)]
168169
#![feature(duration_consts_float)]
169170
#![feature(internal_impls_macro)]
170171
#![feature(ip)]
@@ -248,6 +249,7 @@
248249
#![feature(transparent_unions)]
249250
#![feature(try_blocks)]
250251
#![feature(unboxed_closures)]
252+
#![feature(unsized_const_params)]
251253
#![feature(unsized_fn_params)]
252254
#![feature(with_negative_coherence)]
253255
// tidy-alphabetical-end

core/src/marker.rs

+49-7
Original file line numberDiff line numberDiff line change
@@ -975,31 +975,73 @@ pub trait PointerLike {}
975975
/// that all fields are also `ConstParamTy`, which implies that recursively, all fields
976976
/// are `StructuralPartialEq`.
977977
#[lang = "const_param_ty"]
978-
#[unstable(feature = "adt_const_params", issue = "95174")]
978+
#[unstable(feature = "unsized_const_params", issue = "95174")]
979979
#[diagnostic::on_unimplemented(message = "`{Self}` can't be used as a const parameter type")]
980980
#[allow(multiple_supertrait_upcastable)]
981-
pub trait ConstParamTy: StructuralPartialEq + Eq {}
981+
// We name this differently than the derive macro so that the `adt_const_params` can
982+
// be used independently of `unsized_const_params` without requiring a full path
983+
// to the derive macro every time it is used. This should be renamed on stabilization.
984+
pub trait ConstParamTy_: UnsizedConstParamTy + StructuralPartialEq + Eq {}
982985

983986
/// Derive macro generating an impl of the trait `ConstParamTy`.
984987
#[rustc_builtin_macro]
988+
#[allow_internal_unstable(unsized_const_params)]
985989
#[unstable(feature = "adt_const_params", issue = "95174")]
986990
pub macro ConstParamTy($item:item) {
987991
/* compiler built-in */
988992
}
989993

994+
#[cfg_attr(not(bootstrap), lang = "unsized_const_param_ty")]
995+
#[unstable(feature = "unsized_const_params", issue = "95174")]
996+
#[diagnostic::on_unimplemented(message = "`{Self}` can't be used as a const parameter type")]
997+
/// A marker for types which can be used as types of `const` generic parameters.
998+
///
999+
/// Equivalent to [`ConstParamTy_`] except that this is used by
1000+
/// the `unsized_const_params` to allow for fake unstable impls.
1001+
pub trait UnsizedConstParamTy: StructuralPartialEq + Eq {}
1002+
1003+
/// Derive macro generating an impl of the trait `ConstParamTy`.
1004+
#[cfg(not(bootstrap))]
1005+
#[cfg_attr(not(bootstrap), rustc_builtin_macro)]
1006+
#[cfg_attr(not(bootstrap), allow_internal_unstable(unsized_const_params))]
1007+
#[cfg_attr(not(bootstrap), unstable(feature = "unsized_const_params", issue = "95174"))]
1008+
pub macro UnsizedConstParamTy($item:item) {
1009+
/* compiler built-in */
1010+
}
1011+
9901012
// FIXME(adt_const_params): handle `ty::FnDef`/`ty::Closure`
9911013
marker_impls! {
9921014
#[unstable(feature = "adt_const_params", issue = "95174")]
993-
ConstParamTy for
1015+
ConstParamTy_ for
1016+
usize, u8, u16, u32, u64, u128,
1017+
isize, i8, i16, i32, i64, i128,
1018+
bool,
1019+
char,
1020+
(),
1021+
{T: ConstParamTy_, const N: usize} [T; N],
1022+
}
1023+
#[cfg(bootstrap)]
1024+
marker_impls! {
1025+
#[unstable(feature = "adt_const_params", issue = "95174")]
1026+
ConstParamTy_ for
1027+
str,
1028+
{T: ConstParamTy_} [T],
1029+
{T: ConstParamTy_ + ?Sized} &T,
1030+
}
1031+
1032+
marker_impls! {
1033+
#[unstable(feature = "unsized_const_params", issue = "95174")]
1034+
UnsizedConstParamTy for
9941035
usize, u8, u16, u32, u64, u128,
9951036
isize, i8, i16, i32, i64, i128,
9961037
bool,
9971038
char,
998-
str /* Technically requires `[u8]: ConstParamTy` */,
9991039
(),
1000-
{T: ConstParamTy, const N: usize} [T; N],
1001-
{T: ConstParamTy} [T],
1002-
{T: ?Sized + ConstParamTy} &T,
1040+
{T: UnsizedConstParamTy, const N: usize} [T; N],
1041+
1042+
str,
1043+
{T: UnsizedConstParamTy} [T],
1044+
{T: UnsizedConstParamTy + ?Sized} &T,
10031045
}
10041046

10051047
/// A common trait implemented by all function pointers.

core/src/mem/transmutability.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::marker::ConstParamTy;
1+
use crate::marker::{ConstParamTy_, UnsizedConstParamTy};
22

33
/// Are values of a type transmutable into values of another type?
44
///
@@ -39,7 +39,9 @@ pub struct Assume {
3939
}
4040

4141
#[unstable(feature = "transmutability", issue = "99571")]
42-
impl ConstParamTy for Assume {}
42+
impl ConstParamTy_ for Assume {}
43+
#[unstable(feature = "transmutability", issue = "99571")]
44+
impl UnsizedConstParamTy for Assume {}
4345

4446
impl Assume {
4547
/// Do not assume that *you* have ensured any safety properties are met.

core/src/option.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2507,6 +2507,7 @@ impl<T> ops::FromResidual for Option<T> {
25072507
}
25082508
}
25092509

2510+
#[diagnostic::do_not_recommend]
25102511
#[unstable(feature = "try_trait_v2_yeet", issue = "96374")]
25112512
impl<T> ops::FromResidual<ops::Yeet<()>> for Option<T> {
25122513
#[inline]

core/src/result.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,7 @@ impl<T, E, F: From<E>> ops::FromResidual<Result<convert::Infallible, E>> for Res
19901990
}
19911991
}
19921992
}
1993-
1993+
#[diagnostic::do_not_recommend]
19941994
#[unstable(feature = "try_trait_v2_yeet", issue = "96374")]
19951995
impl<T, E, F: From<E>> ops::FromResidual<ops::Yeet<E>> for Result<T, F> {
19961996
#[inline]

core/src/tuple.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// See core/src/primitive_docs.rs for documentation.
22

33
use crate::cmp::Ordering::{self, *};
4-
use crate::marker::ConstParamTy;
4+
use crate::marker::ConstParamTy_;
55
use crate::marker::StructuralPartialEq;
6+
use crate::marker::UnsizedConstParamTy;
67

78
// Recursive macro for implementing n-ary tuple functions and operations
89
//
@@ -49,8 +50,15 @@ macro_rules! tuple_impls {
4950

5051
maybe_tuple_doc! {
5152
$($T)+ @
52-
#[unstable(feature = "structural_match", issue = "31434")]
53-
impl<$($T: ConstParamTy),+> ConstParamTy for ($($T,)+)
53+
#[unstable(feature = "adt_const_params", issue = "95174")]
54+
impl<$($T: ConstParamTy_),+> ConstParamTy_ for ($($T,)+)
55+
{}
56+
}
57+
58+
maybe_tuple_doc! {
59+
$($T)+ @
60+
#[unstable(feature = "unsized_const_params", issue = "95174")]
61+
impl<$($T: UnsizedConstParamTy),+> UnsizedConstParamTy for ($($T,)+)
5462
{}
5563
}
5664

panic_unwind/src/seh.rs

+6
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ mod imp {
157157
// going to be cross-lang LTOed anyway. However, using expose is shorter and
158158
// requires less unsafe.
159159
let addr: usize = ptr.expose_provenance();
160+
#[cfg(bootstrap)]
160161
let image_base = unsafe { addr_of!(__ImageBase) }.addr();
162+
#[cfg(not(bootstrap))]
163+
let image_base = addr_of!(__ImageBase).addr();
161164
let offset: usize = addr - image_base;
162165
Self(offset as u32)
163166
}
@@ -250,7 +253,10 @@ extern "C" {
250253
// This is fine since the MSVC runtime uses string comparison on the type name
251254
// to match TypeDescriptors rather than pointer equality.
252255
static mut TYPE_DESCRIPTOR: _TypeDescriptor = _TypeDescriptor {
256+
#[cfg(bootstrap)]
253257
pVFTable: unsafe { addr_of!(TYPE_INFO_VTABLE) } as *const _,
258+
#[cfg(not(bootstrap))]
259+
pVFTable: addr_of!(TYPE_INFO_VTABLE) as *const _,
254260
spare: core::ptr::null_mut(),
255261
name: TYPE_NAME,
256262
};

std/Cargo.toml

+45-13
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ core = { path = "../core", public = true }
2020
compiler_builtins = { version = "0.1.105" }
2121
profiler_builtins = { path = "../profiler_builtins", optional = true }
2222
unwind = { path = "../unwind" }
23-
hashbrown = { version = "0.14", default-features = false, features = ['rustc-dep-of-std'] }
24-
std_detect = { path = "../stdarch/crates/std_detect", default-features = false, features = ['rustc-dep-of-std'] }
23+
hashbrown = { version = "0.14", default-features = false, features = [
24+
'rustc-dep-of-std',
25+
] }
26+
std_detect = { path = "../stdarch/crates/std_detect", default-features = false, features = [
27+
'rustc-dep-of-std',
28+
] }
2529

2630
# Dependencies of the `backtrace` crate
2731
rustc-demangle = { version = "0.1.24", features = ['rustc-dep-of-std'] }
@@ -31,13 +35,27 @@ miniz_oxide = { version = "0.7.0", optional = true, default-features = false }
3135
addr2line = { version = "0.22.0", optional = true, default-features = false }
3236

3337
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
34-
libc = { version = "0.2.153", default-features = false, features = ['rustc-dep-of-std'], public = true }
38+
libc = { version = "0.2.153", default-features = false, features = [
39+
'rustc-dep-of-std',
40+
], public = true }
3541

3642
[target.'cfg(all(not(target_os = "aix"), not(all(windows, target_env = "msvc", not(target_vendor = "uwp")))))'.dependencies]
37-
object = { version = "0.36.0", default-features = false, optional = true, features = ['read_core', 'elf', 'macho', 'pe', 'unaligned', 'archive'] }
43+
object = { version = "0.36.0", default-features = false, optional = true, features = [
44+
'read_core',
45+
'elf',
46+
'macho',
47+
'pe',
48+
'unaligned',
49+
'archive',
50+
] }
3851

3952
[target.'cfg(target_os = "aix")'.dependencies]
40-
object = { version = "0.36.0", default-features = false, optional = true, features = ['read_core', 'xcoff', 'unaligned', 'archive'] }
53+
object = { version = "0.36.0", default-features = false, optional = true, features = [
54+
'read_core',
55+
'xcoff',
56+
'unaligned',
57+
'archive',
58+
] }
4159

4260
[dev-dependencies]
4361
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }
@@ -47,23 +65,29 @@ rand_xorshift = "0.3.0"
4765
dlmalloc = { version = "0.2.4", features = ['rustc-dep-of-std'] }
4866

4967
[target.x86_64-fortanix-unknown-sgx.dependencies]
50-
fortanix-sgx-abi = { version = "0.5.0", features = ['rustc-dep-of-std'], public = true }
68+
fortanix-sgx-abi = { version = "0.5.0", features = [
69+
'rustc-dep-of-std',
70+
], public = true }
5171

5272
[target.'cfg(target_os = "hermit")'.dependencies]
53-
hermit-abi = { version = "0.4.0", features = ['rustc-dep-of-std'], public = true }
73+
hermit-abi = { version = "0.4.0", features = [
74+
'rustc-dep-of-std',
75+
], public = true }
5476

5577
[target.'cfg(target_os = "wasi")'.dependencies]
56-
wasi = { version = "0.11.0", features = ['rustc-dep-of-std'], default-features = false }
78+
wasi = { version = "0.11.0", features = [
79+
'rustc-dep-of-std',
80+
], default-features = false }
5781

5882
[target.'cfg(target_os = "uefi")'.dependencies]
59-
r-efi = { version = "4.2.0", features = ['rustc-dep-of-std'] }
83+
r-efi = { version = "4.5.0", features = ['rustc-dep-of-std'] }
6084
r-efi-alloc = { version = "1.0.0", features = ['rustc-dep-of-std'] }
6185

6286
[features]
6387
backtrace = [
64-
'addr2line/rustc-dep-of-std',
65-
'object/rustc-dep-of-std',
66-
'miniz_oxide/rustc-dep-of-std',
88+
'addr2line/rustc-dep-of-std',
89+
'object/rustc-dep-of-std',
90+
'miniz_oxide/rustc-dep-of-std',
6791
]
6892

6993
panic-unwind = ["panic_unwind"]
@@ -77,7 +101,10 @@ llvm-libunwind = ["unwind/llvm-libunwind"]
77101
system-llvm-libunwind = ["unwind/system-llvm-libunwind"]
78102

79103
# Make panics and failed asserts immediately abort without formatting any message
80-
panic_immediate_abort = ["core/panic_immediate_abort", "alloc/panic_immediate_abort"]
104+
panic_immediate_abort = [
105+
"core/panic_immediate_abort",
106+
"alloc/panic_immediate_abort",
107+
]
81108
# Choose algorithms that are optimized for binary size instead of runtime performance
82109
optimize_for_size = ["core/optimize_for_size", "alloc/optimize_for_size"]
83110

@@ -97,6 +124,11 @@ threads = 125
97124
# Maximum heap size
98125
heap_size = 0x8000000
99126

127+
[[test]]
128+
name = "pipe-subprocess"
129+
path = "tests/pipe_subprocess.rs"
130+
harness = false
131+
100132
[[bench]]
101133
name = "stdbenches"
102134
path = "benches/lib.rs"

0 commit comments

Comments
 (0)