fix rustfmt and bless tidy/tests

This commit is contained in:
Deadbeef
2025-12-21 14:11:40 -05:00
parent cf61cbcb07
commit a913065d80
6 changed files with 80 additions and 95 deletions
+1 -1
View File
@@ -108,9 +108,9 @@
#![feature(const_destruct)]
#![feature(const_eval_select)]
#![feature(const_heap)]
#![feature(copied_into_inner)]
#![feature(const_option_ops)]
#![feature(const_try)]
#![feature(copied_into_inner)]
#![feature(core_intrinsics)]
#![feature(deprecated_suggestion)]
#![feature(deref_pure_trait)]
+12 -22
View File
@@ -165,14 +165,14 @@ const fn min_non_zero_cap(size: usize) -> usize {
}
}
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
#[rustfmt::skip] // FIXME(fee1-dead): temporary measure before rustfmt is bumped
const impl<T, A: [const] Allocator + [const] Destruct> RawVec<T, A> {
/// Like `with_capacity`, but parameterized over the choice of
/// allocator for the returned `RawVec`.
#[cfg(not(no_global_oom_handling))]
#[inline]
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
pub(crate) fn with_capacity_in(capacity: usize, alloc: A) -> Self
{
pub(crate) fn with_capacity_in(capacity: usize, alloc: A) -> Self {
Self {
inner: RawVecInner::with_capacity_in(capacity, alloc, T::LAYOUT),
_marker: PhantomData,
@@ -183,9 +183,7 @@ pub(crate) fn with_capacity_in(capacity: usize, alloc: A) -> Self
/// caller to ensure `len == self.capacity()`.
#[cfg(not(no_global_oom_handling))]
#[inline(never)]
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
pub(crate) fn grow_one(&mut self)
{
pub(crate) fn grow_one(&mut self) {
// SAFETY: All calls on self.inner pass T::LAYOUT as the elem_layout
unsafe { self.inner.grow_one(T::LAYOUT) }
}
@@ -411,12 +409,12 @@ fn drop(&mut self) {
}
}
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
#[rustfmt::skip] // FIXME(fee1-dead): temporary measure before rustfmt is bumped
const impl<A: [const] Allocator + [const] Destruct> RawVecInner<A> {
#[cfg(not(no_global_oom_handling))]
#[inline]
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
fn with_capacity_in(capacity: usize, alloc: A, elem_layout: Layout) -> Self
{
fn with_capacity_in(capacity: usize, alloc: A, elem_layout: Layout) -> Self {
match Self::try_allocate_in(capacity, AllocInit::Uninitialized, alloc, elem_layout) {
Ok(this) => {
unsafe {
@@ -428,14 +426,13 @@ fn with_capacity_in(capacity: usize, alloc: A, elem_layout: Layout) -> Self
Err(err) => handle_error(err),
}
}
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
fn try_allocate_in(
capacity: usize,
init: AllocInit,
alloc: A,
elem_layout: Layout,
) -> Result<Self, TryReserveError>
{
) -> Result<Self, TryReserveError> {
// We avoid `unwrap_or_else` here because it bloats the amount of
// LLVM IR generated.
let layout = match layout_array(capacity, elem_layout) {
@@ -474,29 +471,24 @@ fn try_allocate_in(
/// - `elem_layout`'s size must be a multiple of its alignment
#[cfg(not(no_global_oom_handling))]
#[inline]
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
unsafe fn grow_one(&mut self, elem_layout: Layout)
{
unsafe fn grow_one(&mut self, elem_layout: Layout) {
// SAFETY: Precondition passed to caller
if let Err(err) = unsafe { self.grow_amortized(self.cap.as_inner(), 1, elem_layout) } {
handle_error(err);
}
}
/// # Safety
/// - `elem_layout` must be valid for `self`, i.e. it must be the same `elem_layout` used to
/// initially construct `self`
/// - `elem_layout`'s size must be a multiple of its alignment
/// - The sum of `len` and `additional` must be greater than the current capacity
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
unsafe fn grow_amortized(
&mut self,
len: usize,
additional: usize,
elem_layout: Layout,
) -> Result<(), TryReserveError>
{
) -> Result<(), TryReserveError> {
// This is ensured by the calling contexts.
debug_assert!(additional > 0);
@@ -532,13 +524,11 @@ unsafe fn grow_amortized(
// not marked inline(never) since we want optimizers to be able to observe the specifics of this
// function, see tests/codegen-llvm/vec-reserve-extend.rs.
#[cold]
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
unsafe fn finish_grow(
&self,
cap: usize,
elem_layout: Layout,
) -> Result<NonNull<[u8]>, TryReserveError>
{
) -> Result<NonNull<[u8]>, TryReserveError> {
let new_layout = layout_array(cap, elem_layout)?;
let memory = if let Some((ptr, old_layout)) = unsafe { self.current_memory(elem_layout) } {
+6 -13
View File
@@ -902,6 +902,9 @@ pub const fn const_make_global(mut self) -> &'static [T]
}
}
#[cfg(not(no_global_oom_handling))]
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
#[rustfmt::skip] // FIXME(fee1-dead): temporary measure before rustfmt is bumped
const impl<T, A: [const] Allocator + [const] Destruct> Vec<T, A> {
/// Constructs a new, empty `Vec<T, A>` with at least the specified capacity
/// with the provided allocator.
@@ -958,16 +961,12 @@ const impl<T, A: [const] Allocator + [const] Destruct> Vec<T, A> {
/// let vec_units = Vec::<(), System>::with_capacity_in(10, System);
/// assert_eq!(vec_units.capacity(), usize::MAX);
/// ```
#[cfg(not(no_global_oom_handling))]
#[inline]
#[unstable(feature = "allocator_api", issue = "32838")]
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
pub fn with_capacity_in(capacity: usize, alloc: A) -> Self
{
pub fn with_capacity_in(capacity: usize, alloc: A) -> Self {
Vec { buf: RawVec::with_capacity_in(capacity, alloc), len: 0 }
}
/// Appends an element to the back of a collection.
///
/// # Panics
@@ -988,13 +987,10 @@ pub fn with_capacity_in(capacity: usize, alloc: A) -> Self
/// capacity after the push, *O*(*capacity*) time is taken to copy the
/// vector's elements to a larger allocation. This expensive operation is
/// offset by the *capacity* *O*(1) insertions it allows.
#[cfg(not(no_global_oom_handling))]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_confusables("push_back", "put", "append")]
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
pub fn push(&mut self, value: T)
{
pub fn push(&mut self, value: T) {
let _ = self.push_mut(value);
}
@@ -1026,13 +1022,10 @@ pub fn push(&mut self, value: T)
/// capacity after the push, *O*(*capacity*) time is taken to copy the
/// vector's elements to a larger allocation. This expensive operation is
/// offset by the *capacity* *O*(1) insertions it allows.
#[cfg(not(no_global_oom_handling))]
#[inline]
#[unstable(feature = "push_mut", issue = "135974")]
#[must_use = "if you don't need a reference to the value, use `Vec::push` instead"]
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
pub fn push_mut(&mut self, value: T) -> &mut T
{
pub fn push_mut(&mut self, value: T) -> &mut T {
// Inform codegen that the length does not change across grow_one().
let len = self.len;
// This will panic or abort if we would allocate > isize::MAX bytes
@@ -26,12 +26,12 @@
scope 4 {
debug _x => _8;
}
scope 18 (inlined foo) {
scope 19 (inlined foo) {
let mut _27: *const [()];
}
}
scope 16 (inlined slice_from_raw_parts::<()>) {
scope 17 (inlined std::ptr::from_raw_parts::<[()], ()>) {
scope 17 (inlined slice_from_raw_parts::<()>) {
scope 18 (inlined std::ptr::from_raw_parts::<[()], ()>) {
}
}
}
@@ -49,19 +49,21 @@
scope 7 {
let _21: std::ptr::NonNull<[u8]>;
scope 8 {
scope 11 (inlined NonNull::<[u8]>::as_mut_ptr) {
scope 12 (inlined NonNull::<[u8]>::as_non_null_ptr) {
scope 13 (inlined NonNull::<[u8]>::cast::<u8>) {
scope 12 (inlined NonNull::<[u8]>::as_mut_ptr) {
scope 13 (inlined NonNull::<[u8]>::as_non_null_ptr) {
scope 14 (inlined NonNull::<[u8]>::cast::<u8>) {
let mut _25: *mut [u8];
scope 14 (inlined NonNull::<[u8]>::as_ptr) {
scope 15 (inlined NonNull::<[u8]>::as_ptr) {
}
}
}
scope 15 (inlined NonNull::<u8>::as_ptr) {
scope 16 (inlined NonNull::<u8>::as_ptr) {
}
}
}
scope 10 (inlined <std::alloc::Global as Allocator>::allocate) {
scope 11 (inlined std::alloc::Global::alloc_impl) {
}
}
}
scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) {
@@ -192,8 +194,8 @@
+ _18 = const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }};
StorageDead(_24);
StorageLive(_19);
- _19 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], copy _18, const false) -> [return: bb7, unwind unreachable];
+ _19 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}, const false) -> [return: bb7, unwind unreachable];
- _19 = std::alloc::Global::alloc_impl_runtime(copy _18, const false) -> [return: bb7, unwind unreachable];
+ _19 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}, const false) -> [return: bb7, unwind unreachable];
}
bb7: {
@@ -25,17 +25,21 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
}
}
scope 18 (inlined <std::alloc::Global as Allocator>::deallocate) {
let mut _9: *mut u8;
scope 19 (inlined Layout::size) {
}
scope 20 (inlined NonNull::<u8>::as_ptr) {
}
scope 21 (inlined std::alloc::dealloc) {
let mut _10: usize;
scope 22 (inlined Layout::size) {
}
scope 23 (inlined Layout::align) {
scope 24 (inlined std::ptr::Alignment::as_usize) {
scope 19 (inlined std::alloc::Global::deallocate_impl) {
scope 20 (inlined std::alloc::Global::deallocate_impl_runtime) {
let mut _9: *mut u8;
scope 21 (inlined Layout::size) {
}
scope 22 (inlined NonNull::<u8>::as_ptr) {
}
scope 23 (inlined std::alloc::dealloc) {
let mut _10: usize;
scope 24 (inlined Layout::size) {
}
scope 25 (inlined Layout::align) {
scope 26 (inlined std::ptr::Alignment::as_usize) {
}
}
}
}
}
@@ -9,33 +9,33 @@
let mut _4: *mut [u8];
let mut _5: std::ptr::NonNull<[u8]>;
let mut _6: std::result::Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError>;
let mut _7: &std::alloc::Global;
let mut _8: std::alloc::Layout;
let mut _7: std::alloc::Layout;
scope 1 {
debug layout => _1;
let mut _9: &std::alloc::Global;
scope 2 {
debug ptr => _3;
}
scope 5 (inlined <std::alloc::Global as Allocator>::allocate) {
}
scope 6 (inlined #[track_caller] Result::<NonNull<[u8]>, std::alloc::AllocError>::unwrap) {
let mut _12: isize;
let _13: std::alloc::AllocError;
let mut _14: !;
let mut _15: &dyn std::fmt::Debug;
let _16: &std::alloc::AllocError;
scope 7 {
scope 6 (inlined std::alloc::Global::alloc_impl) {
}
}
scope 7 (inlined #[track_caller] Result::<NonNull<[u8]>, std::alloc::AllocError>::unwrap) {
let mut _10: isize;
let _11: std::alloc::AllocError;
let mut _12: !;
let mut _13: &dyn std::fmt::Debug;
let _14: &std::alloc::AllocError;
scope 8 {
}
scope 9 {
}
}
scope 9 (inlined NonNull::<[u8]>::as_ptr) {
scope 10 (inlined NonNull::<[u8]>::as_ptr) {
}
}
scope 3 (inlined #[track_caller] Option::<Layout>::unwrap) {
let mut _10: isize;
let mut _11: !;
let mut _8: isize;
let mut _9: !;
scope 4 {
}
}
@@ -46,10 +46,10 @@
StorageLive(_2);
- _2 = Option::<Layout>::None;
+ _2 = const Option::<Layout>::None;
StorageLive(_10);
- _10 = discriminant(_2);
- switchInt(move _10) -> [0: bb2, 1: bb3, otherwise: bb1];
+ _10 = const 0_isize;
StorageLive(_8);
- _8 = discriminant(_2);
- switchInt(move _8) -> [0: bb2, 1: bb3, otherwise: bb1];
+ _8 = const 0_isize;
+ switchInt(const 0_isize) -> [0: bb2, 1: bb3, otherwise: bb1];
}
@@ -58,48 +58,44 @@
}
bb2: {
_11 = option::unwrap_failed() -> unwind unreachable;
_9 = option::unwrap_failed() -> unwind unreachable;
}
bb3: {
- _1 = move ((_2 as Some).0: std::alloc::Layout);
+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }};
StorageDead(_10);
StorageDead(_8);
StorageDead(_2);
StorageLive(_3);
StorageLive(_4);
StorageLive(_5);
StorageLive(_6);
StorageLive(_7);
_9 = const main::promoted[0];
_7 = copy _9;
StorageLive(_8);
- _8 = copy _1;
- _6 = std::alloc::Global::alloc_impl(move _7, move _8, const false) -> [return: bb4, unwind unreachable];
+ _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }};
+ _6 = std::alloc::Global::alloc_impl(copy _9, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb4, unwind unreachable];
- _7 = copy _1;
- _6 = std::alloc::Global::alloc_impl_runtime(move _7, const false) -> [return: bb4, unwind unreachable];
+ _7 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }};
+ _6 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb4, unwind unreachable];
}
bb4: {
StorageDead(_8);
StorageDead(_7);
StorageLive(_12);
StorageLive(_16);
_12 = discriminant(_6);
switchInt(move _12) -> [0: bb6, 1: bb5, otherwise: bb1];
StorageLive(_10);
StorageLive(_14);
_10 = discriminant(_6);
switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb1];
}
bb5: {
StorageLive(_15);
_16 = &_13;
_15 = copy _16 as &dyn std::fmt::Debug (PointerCoercion(Unsize, Implicit));
_14 = result::unwrap_failed(const "called `Result::unwrap()` on an `Err` value", move _15) -> unwind unreachable;
StorageLive(_13);
_14 = &_11;
_13 = copy _14 as &dyn std::fmt::Debug (PointerCoercion(Unsize, Implicit));
_12 = result::unwrap_failed(const "called `Result::unwrap()` on an `Err` value", move _13) -> unwind unreachable;
}
bb6: {
_5 = move ((_6 as Ok).0: std::ptr::NonNull<[u8]>);
StorageDead(_16);
StorageDead(_12);
StorageDead(_14);
StorageDead(_10);
StorageDead(_6);
_4 = copy _5 as *mut [u8] (Transmute);
StorageDead(_5);