Skip to content
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

Rollup of 6 pull requests #135357

Merged
merged 18 commits into from
Jan 11, 2025
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4ba139d
bootstrap: `std::io::ErrorKind::CrossesDevices` is finally stable
GrigorenkoPV Dec 9, 2024
e1772e7
re-add a warning for old master branch, but with much simpler logic
lolbinarycat Jan 9, 2025
e21d125
Initial fs module for uefi
Ayush1325 Jan 10, 2025
6f2a783
Update a bunch of library types for MCP807
scottmcm Jan 8, 2025
4fd82f7
make `optimized-compiler-builtins` target configurable
onur-ozkan Jan 10, 2025
e02957a
add coverage for target specific value
onur-ozkan Jan 10, 2025
37eb9fa
ensure `optimized_compiler_builtins` check for CI rustc
onur-ozkan Jan 10, 2025
8f63485
add `optimized-compiler-builtins` to target specific section
onur-ozkan Jan 10, 2025
5a19c26
add change entry for `optimized-compiler-builtins`
onur-ozkan Jan 10, 2025
9ab77f1
Use `NonNull::without_provenance` within the standard library
samueltardieu Jan 10, 2025
60cbd74
never print the warning on CI
lolbinarycat Jan 11, 2025
ebd6d3f
Improve the safety documentation on new_unchecked
scottmcm Jan 11, 2025
bd81023
Rollup merge of #134074 - GrigorenkoPV:bootstrap-io-error-more, r=jie…
jhpratt Jan 11, 2025
351e618
Rollup merge of #135236 - scottmcm:more-mcp807-library-updates, r=Chr…
jhpratt Jan 11, 2025
8c3e9d7
Rollup merge of #135301 - lolbinarycat:bootstrap-old-master-resurecte…
jhpratt Jan 11, 2025
23c22a6
Rollup merge of #135324 - Ayush1325:uefi-fs-unsupported, r=joboet
jhpratt Jan 11, 2025
538d5dc
Rollup merge of #135326 - onur-ozkan:target-specific-compiler-builtin…
jhpratt Jan 11, 2025
46222ce
Rollup merge of #135347 - samueltardieu:push-qvyxtxsqyxyr, r=jhpratt
jhpratt Jan 11, 2025
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
9 changes: 9 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
@@ -922,6 +922,15 @@
# argument as the test binary.
#runner = <none> (string)

# Use the optimized LLVM C intrinsics for `compiler_builtins`, rather than Rust intrinsics
# on this target.
# Requires the LLVM submodule to be managed by bootstrap (i.e. not external) so that `compiler-rt`
# sources are available.
#
# Setting this to `false` generates slower code, but removes the requirement for a C toolchain in
# order to run `x check`.
#optimized-compiler-builtins = build.optimized-compiler-builtins (bool)

# =============================================================================
# Distribution options
#
2 changes: 2 additions & 0 deletions library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -126,6 +126,7 @@
#![feature(local_waker)]
#![feature(maybe_uninit_slice)]
#![feature(maybe_uninit_uninit_array_transpose)]
#![feature(nonnull_provenance)]
#![feature(panic_internals)]
#![feature(pattern)]
#![feature(pin_coerce_unsized_trait)]
@@ -142,6 +143,7 @@
#![feature(slice_range)]
#![feature(std_internals)]
#![feature(str_internals)]
#![feature(temporary_niche_types)]
#![feature(trusted_fused)]
#![feature(trusted_len)]
#![feature(trusted_random_access)]
46 changes: 22 additions & 24 deletions library/alloc/src/raw_vec.rs
Original file line number Diff line number Diff line change
@@ -33,21 +33,15 @@ enum AllocInit {
Zeroed,
}

#[repr(transparent)]
#[cfg_attr(target_pointer_width = "16", rustc_layout_scalar_valid_range_end(0x7fff))]
#[cfg_attr(target_pointer_width = "32", rustc_layout_scalar_valid_range_end(0x7fff_ffff))]
#[cfg_attr(target_pointer_width = "64", rustc_layout_scalar_valid_range_end(0x7fff_ffff_ffff_ffff))]
struct Cap(usize);
type Cap = core::num::niche_types::UsizeNoHighBit;

impl Cap {
const ZERO: Cap = unsafe { Cap(0) };
const ZERO_CAP: Cap = unsafe { Cap::new_unchecked(0) };

/// `Cap(cap)`, except if `T` is a ZST then `Cap::ZERO`.
///
/// # Safety: cap must be <= `isize::MAX`.
unsafe fn new<T>(cap: usize) -> Self {
if T::IS_ZST { Cap::ZERO } else { unsafe { Self(cap) } }
}
/// `Cap(cap)`, except if `T` is a ZST then `Cap::ZERO`.
///
/// # Safety: cap must be <= `isize::MAX`.
unsafe fn new_cap<T>(cap: usize) -> Cap {
if T::IS_ZST { ZERO_CAP } else { unsafe { Cap::new_unchecked(cap) } }
}

/// A low-level utility for more ergonomically allocating, reallocating, and deallocating
@@ -257,7 +251,7 @@ impl<T, A: Allocator> RawVec<T, A> {
// SAFETY: Precondition passed to the caller
unsafe {
let ptr = ptr.cast();
let capacity = Cap::new::<T>(capacity);
let capacity = new_cap::<T>(capacity);
Self {
inner: RawVecInner::from_raw_parts_in(ptr, capacity, alloc),
_marker: PhantomData,
@@ -275,7 +269,7 @@ impl<T, A: Allocator> RawVec<T, A> {
// SAFETY: Precondition passed to the caller
unsafe {
let ptr = ptr.cast();
let capacity = Cap::new::<T>(capacity);
let capacity = new_cap::<T>(capacity);
Self { inner: RawVecInner::from_nonnull_in(ptr, capacity, alloc), _marker: PhantomData }
}
}
@@ -410,7 +404,7 @@ impl<A: Allocator> RawVecInner<A> {
const fn new_in(alloc: A, align: usize) -> Self {
let ptr = unsafe { core::mem::transmute(align) };
// `cap: 0` means "unallocated". zero-sized types are ignored.
Self { ptr, cap: Cap::ZERO, alloc }
Self { ptr, cap: ZERO_CAP, alloc }
}

#[cfg(not(no_global_oom_handling))]
@@ -483,7 +477,11 @@ impl<A: Allocator> RawVecInner<A> {
// Allocators currently return a `NonNull<[u8]>` whose length
// matches the size requested. If that ever changes, the capacity
// here should change to `ptr.len() / mem::size_of::<T>()`.
Ok(Self { ptr: Unique::from(ptr.cast()), cap: unsafe { Cap(capacity) }, alloc })
Ok(Self {
ptr: Unique::from(ptr.cast()),
cap: unsafe { Cap::new_unchecked(capacity) },
alloc,
})
}

#[inline]
@@ -508,7 +506,7 @@ impl<A: Allocator> RawVecInner<A> {

#[inline]
const fn capacity(&self, elem_size: usize) -> usize {
if elem_size == 0 { usize::MAX } else { self.cap.0 }
if elem_size == 0 { usize::MAX } else { self.cap.as_inner() }
}

#[inline]
@@ -518,15 +516,15 @@ impl<A: Allocator> RawVecInner<A> {

#[inline]
fn current_memory(&self, elem_layout: Layout) -> Option<(NonNull<u8>, Layout)> {
if elem_layout.size() == 0 || self.cap.0 == 0 {
if elem_layout.size() == 0 || self.cap.as_inner() == 0 {
None
} else {
// We could use Layout::array here which ensures the absence of isize and usize overflows
// and could hypothetically handle differences between stride and size, but this memory
// has already been allocated so we know it can't overflow and currently Rust does not
// support such types. So we can do better by skipping some checks and avoid an unwrap.
unsafe {
let alloc_size = elem_layout.size().unchecked_mul(self.cap.0);
let alloc_size = elem_layout.size().unchecked_mul(self.cap.as_inner());
let layout = Layout::from_size_align_unchecked(alloc_size, elem_layout.align());
Some((self.ptr.into(), layout))
}
@@ -562,7 +560,7 @@ impl<A: Allocator> RawVecInner<A> {
#[inline]
#[track_caller]
fn grow_one(&mut self, elem_layout: Layout) {
if let Err(err) = self.grow_amortized(self.cap.0, 1, elem_layout) {
if let Err(err) = self.grow_amortized(self.cap.as_inner(), 1, elem_layout) {
handle_error(err);
}
}
@@ -627,7 +625,7 @@ impl<A: Allocator> RawVecInner<A> {
// the size requested. If that ever changes, the capacity here should
// change to `ptr.len() / mem::size_of::<T>()`.
self.ptr = Unique::from(ptr.cast());
self.cap = unsafe { Cap(cap) };
self.cap = unsafe { Cap::new_unchecked(cap) };
}

fn grow_amortized(
@@ -650,7 +648,7 @@ impl<A: Allocator> RawVecInner<A> {

// This guarantees exponential growth. The doubling cannot overflow
// because `cap <= isize::MAX` and the type of `cap` is `usize`.
let cap = cmp::max(self.cap.0 * 2, required_cap);
let cap = cmp::max(self.cap.as_inner() * 2, required_cap);
let cap = cmp::max(min_non_zero_cap(elem_layout.size()), cap);

let new_layout = layout_array(cap, elem_layout)?;
@@ -719,7 +717,7 @@ impl<A: Allocator> RawVecInner<A> {
unsafe { self.alloc.deallocate(ptr, layout) };
self.ptr =
unsafe { Unique::new_unchecked(ptr::without_provenance_mut(elem_layout.align())) };
self.cap = Cap::ZERO;
self.cap = ZERO_CAP;
} else {
let ptr = unsafe {
// Layout cannot overflow here because it would have
15 changes: 3 additions & 12 deletions library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
@@ -252,6 +252,7 @@ use core::intrinsics::abort;
use core::iter;
use core::marker::{PhantomData, Unsize};
use core::mem::{self, ManuallyDrop, align_of_val_raw};
use core::num::NonZeroUsize;
use core::ops::{CoerceUnsized, Deref, DerefMut, DerefPure, DispatchFromDyn, LegacyReceiver};
use core::panic::{RefUnwindSafe, UnwindSafe};
#[cfg(not(no_global_oom_handling))]
@@ -3027,12 +3028,7 @@ impl<T> Weak<T> {
#[rustc_const_stable(feature = "const_weak_new", since = "1.73.0")]
#[must_use]
pub const fn new() -> Weak<T> {
Weak {
ptr: unsafe {
NonNull::new_unchecked(ptr::without_provenance_mut::<RcInner<T>>(usize::MAX))
},
alloc: Global,
}
Weak { ptr: NonNull::without_provenance(NonZeroUsize::MAX), alloc: Global }
}
}

@@ -3054,12 +3050,7 @@ impl<T, A: Allocator> Weak<T, A> {
#[inline]
#[unstable(feature = "allocator_api", issue = "32838")]
pub fn new_in(alloc: A) -> Weak<T, A> {
Weak {
ptr: unsafe {
NonNull::new_unchecked(ptr::without_provenance_mut::<RcInner<T>>(usize::MAX))
},
alloc,
}
Weak { ptr: NonNull::without_provenance(NonZeroUsize::MAX), alloc }
}
}

15 changes: 3 additions & 12 deletions library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ use core::intrinsics::abort;
use core::iter;
use core::marker::{PhantomData, Unsize};
use core::mem::{self, ManuallyDrop, align_of_val_raw};
use core::num::NonZeroUsize;
use core::ops::{CoerceUnsized, Deref, DerefPure, DispatchFromDyn, LegacyReceiver};
use core::panic::{RefUnwindSafe, UnwindSafe};
use core::pin::{Pin, PinCoerceUnsized};
@@ -2687,12 +2688,7 @@ impl<T> Weak<T> {
#[rustc_const_stable(feature = "const_weak_new", since = "1.73.0")]
#[must_use]
pub const fn new() -> Weak<T> {
Weak {
ptr: unsafe {
NonNull::new_unchecked(ptr::without_provenance_mut::<ArcInner<T>>(usize::MAX))
},
alloc: Global,
}
Weak { ptr: NonNull::without_provenance(NonZeroUsize::MAX), alloc: Global }
}
}

@@ -2717,12 +2713,7 @@ impl<T, A: Allocator> Weak<T, A> {
#[inline]
#[unstable(feature = "allocator_api", issue = "32838")]
pub fn new_in(alloc: A) -> Weak<T, A> {
Weak {
ptr: unsafe {
NonNull::new_unchecked(ptr::without_provenance_mut::<ArcInner<T>>(usize::MAX))
},
alloc,
}
Weak { ptr: NonNull::without_provenance(NonZeroUsize::MAX), alloc }
}
}

3 changes: 1 addition & 2 deletions library/core/src/alloc/layout.rs
Original file line number Diff line number Diff line change
@@ -233,8 +233,7 @@ impl Layout {
#[must_use]
#[inline]
pub const fn dangling(&self) -> NonNull<u8> {
// SAFETY: align is guaranteed to be non-zero
unsafe { NonNull::new_unchecked(crate::ptr::without_provenance_mut::<u8>(self.align())) }
NonNull::without_provenance(self.align.as_nonzero())
}

/// Creates a layout describing the record that can hold a value
4 changes: 4 additions & 0 deletions library/core/src/num/mod.rs
Original file line number Diff line number Diff line change
@@ -51,6 +51,10 @@ mod overflow_panic;
mod saturating;
mod wrapping;

/// 100% perma-unstable
#[doc(hidden)]
pub mod niche_types;

#[stable(feature = "rust1", since = "1.0.0")]
#[cfg(not(no_fp_fmt_parse))]
pub use dec2flt::ParseFloatError;
Loading