Skip to content

Commit 1e70279

Browse files
committed
Revert "rust: upgrade to Rust 1.73.0"
This reverts commit e08ff62.
1 parent a796b48 commit 1e70279

File tree

9 files changed

+59
-63
lines changed

9 files changed

+59
-63
lines changed

Documentation/process/changes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ you probably needn't concern yourself with pcmciautils.
3131
====================== =============== ========================================
3232
GNU C 5.1 gcc --version
3333
Clang/LLVM (optional) 11.0.0 clang --version
34-
Rust (optional) 1.73.0 rustc --version
34+
Rust (optional) 1.72.1 rustc --version
3535
bindgen (optional) 0.65.1 bindgen --version
3636
GNU make 3.82 make --version
3737
bash 4.2 bash --version

rust/alloc/alloc.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66

77
#[cfg(not(test))]
88
use core::intrinsics;
9+
#[cfg(all(bootstrap, not(test)))]
10+
use core::intrinsics::{min_align_of_val, size_of_val};
911

12+
#[cfg(all(bootstrap, not(test)))]
13+
use core::ptr::Unique;
1014
#[cfg(not(test))]
1115
use core::ptr::{self, NonNull};
1216

@@ -335,6 +339,23 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
335339
}
336340
}
337341

342+
#[cfg(all(bootstrap, not(test)))]
343+
#[lang = "box_free"]
344+
#[inline]
345+
// This signature has to be the same as `Box`, otherwise an ICE will happen.
346+
// When an additional parameter to `Box` is added (like `A: Allocator`), this has to be added here as
347+
// well.
348+
// For example if `Box` is changed to `struct Box<T: ?Sized, A: Allocator>(Unique<T>, A)`,
349+
// this function has to be changed to `fn box_free<T: ?Sized, A: Allocator>(Unique<T>, A)` as well.
350+
unsafe fn box_free<T: ?Sized, A: Allocator>(ptr: Unique<T>, alloc: A) {
351+
unsafe {
352+
let size = size_of_val(ptr.as_ref());
353+
let align = min_align_of_val(ptr.as_ref());
354+
let layout = Layout::from_size_align_unchecked(size, align);
355+
alloc.deallocate(From::from(ptr.cast()), layout)
356+
}
357+
}
358+
338359
// # Allocation error handler
339360

340361
#[cfg(not(no_global_oom_handling))]
@@ -394,6 +415,7 @@ pub mod __alloc_error_handler {
394415
static __rust_alloc_error_handler_should_panic: u8;
395416
}
396417

418+
#[allow(unused_unsafe)]
397419
if unsafe { __rust_alloc_error_handler_should_panic != 0 } {
398420
panic!("memory allocation of {size} bytes failed")
399421
} else {

rust/alloc/boxed.rs

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,12 @@ use core::hash::{Hash, Hasher};
159159
use core::iter::FusedIterator;
160160
use core::marker::Tuple;
161161
use core::marker::Unsize;
162-
use core::mem::{self, SizedTypeProperties};
162+
use core::mem;
163163
use core::ops::{
164164
CoerceUnsized, Deref, DerefMut, DispatchFromDyn, Generator, GeneratorState, Receiver,
165165
};
166166
use core::pin::Pin;
167-
use core::ptr::{self, NonNull, Unique};
167+
use core::ptr::{self, Unique};
168168
use core::task::{Context, Poll};
169169

170170
#[cfg(not(no_global_oom_handling))]
@@ -483,12 +483,8 @@ impl<T, A: Allocator> Box<T, A> {
483483
where
484484
A: Allocator,
485485
{
486-
let ptr = if T::IS_ZST {
487-
NonNull::dangling()
488-
} else {
489-
let layout = Layout::new::<mem::MaybeUninit<T>>();
490-
alloc.allocate(layout)?.cast()
491-
};
486+
let layout = Layout::new::<mem::MaybeUninit<T>>();
487+
let ptr = alloc.allocate(layout)?.cast();
492488
unsafe { Ok(Box::from_raw_in(ptr.as_ptr(), alloc)) }
493489
}
494490

@@ -557,12 +553,8 @@ impl<T, A: Allocator> Box<T, A> {
557553
where
558554
A: Allocator,
559555
{
560-
let ptr = if T::IS_ZST {
561-
NonNull::dangling()
562-
} else {
563-
let layout = Layout::new::<mem::MaybeUninit<T>>();
564-
alloc.allocate_zeroed(layout)?.cast()
565-
};
556+
let layout = Layout::new::<mem::MaybeUninit<T>>();
557+
let ptr = alloc.allocate_zeroed(layout)?.cast();
566558
unsafe { Ok(Box::from_raw_in(ptr.as_ptr(), alloc)) }
567559
}
568560

@@ -687,16 +679,14 @@ impl<T> Box<[T]> {
687679
#[unstable(feature = "allocator_api", issue = "32838")]
688680
#[inline]
689681
pub fn try_new_uninit_slice(len: usize) -> Result<Box<[mem::MaybeUninit<T>]>, AllocError> {
690-
let ptr = if T::IS_ZST || len == 0 {
691-
NonNull::dangling()
692-
} else {
682+
unsafe {
693683
let layout = match Layout::array::<mem::MaybeUninit<T>>(len) {
694684
Ok(l) => l,
695685
Err(_) => return Err(AllocError),
696686
};
697-
Global.allocate(layout)?.cast()
698-
};
699-
unsafe { Ok(RawVec::from_raw_parts_in(ptr.as_ptr(), len, Global).into_box(len)) }
687+
let ptr = Global.allocate(layout)?;
688+
Ok(RawVec::from_raw_parts_in(ptr.as_mut_ptr() as *mut _, len, Global).into_box(len))
689+
}
700690
}
701691

702692
/// Constructs a new boxed slice with uninitialized contents, with the memory
@@ -721,16 +711,14 @@ impl<T> Box<[T]> {
721711
#[unstable(feature = "allocator_api", issue = "32838")]
722712
#[inline]
723713
pub fn try_new_zeroed_slice(len: usize) -> Result<Box<[mem::MaybeUninit<T>]>, AllocError> {
724-
let ptr = if T::IS_ZST || len == 0 {
725-
NonNull::dangling()
726-
} else {
714+
unsafe {
727715
let layout = match Layout::array::<mem::MaybeUninit<T>>(len) {
728716
Ok(l) => l,
729717
Err(_) => return Err(AllocError),
730718
};
731-
Global.allocate_zeroed(layout)?.cast()
732-
};
733-
unsafe { Ok(RawVec::from_raw_parts_in(ptr.as_ptr(), len, Global).into_box(len)) }
719+
let ptr = Global.allocate_zeroed(layout)?;
720+
Ok(RawVec::from_raw_parts_in(ptr.as_mut_ptr() as *mut _, len, Global).into_box(len))
721+
}
734722
}
735723
}
736724

@@ -1235,9 +1223,7 @@ unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> Drop for Box<T, A> {
12351223

12361224
unsafe {
12371225
let layout = Layout::for_value_raw(ptr.as_ptr());
1238-
if layout.size() != 0 {
1239-
self.1.deallocate(From::from(ptr.cast()), layout);
1240-
}
1226+
self.1.deallocate(From::from(ptr.cast()), layout)
12411227
}
12421228
}
12431229
}
@@ -2187,7 +2173,7 @@ impl dyn Error + Send {
21872173
let err: Box<dyn Error> = self;
21882174
<dyn Error>::downcast(err).map_err(|s| unsafe {
21892175
// Reapply the `Send` marker.
2190-
Box::from_raw(Box::into_raw(s) as *mut (dyn Error + Send))
2176+
mem::transmute::<Box<dyn Error>, Box<dyn Error + Send>>(s)
21912177
})
21922178
}
21932179
}
@@ -2201,7 +2187,7 @@ impl dyn Error + Send + Sync {
22012187
let err: Box<dyn Error> = self;
22022188
<dyn Error>::downcast(err).map_err(|s| unsafe {
22032189
// Reapply the `Send + Sync` marker.
2204-
Box::from_raw(Box::into_raw(s) as *mut (dyn Error + Send + Sync))
2190+
mem::transmute::<Box<dyn Error>, Box<dyn Error + Send + Sync>>(s)
22052191
})
22062192
}
22072193
}

rust/alloc/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
6161
// To run alloc tests without x.py without ending up with two copies of alloc, Miri needs to be
6262
// able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>.
63-
// rustc itself never sets the feature, so this line has no effect there.
63+
// rustc itself never sets the feature, so this line has no affect there.
6464
#![cfg(any(not(feature = "miri-test-libstd"), test, doctest))]
6565
//
6666
#![allow(unused_attributes)]
@@ -90,8 +90,6 @@
9090
#![warn(missing_docs)]
9191
#![allow(explicit_outlives_requirements)]
9292
#![warn(multiple_supertrait_upcastable)]
93-
#![cfg_attr(not(bootstrap), allow(internal_features))]
94-
#![cfg_attr(not(bootstrap), allow(rustdoc::redundant_explicit_links))]
9593
//
9694
// Library features:
9795
// tidy-alphabetical-start
@@ -141,6 +139,7 @@
141139
#![feature(maybe_uninit_uninit_array_transpose)]
142140
#![feature(pattern)]
143141
#![feature(pointer_byte_offsets)]
142+
#![feature(provide_any)]
144143
#![feature(ptr_internals)]
145144
#![feature(ptr_metadata)]
146145
#![feature(ptr_sub_ptr)]

rust/alloc/raw_vec.rs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -471,26 +471,16 @@ impl<T, A: Allocator> RawVec<T, A> {
471471
let (ptr, layout) = if let Some(mem) = self.current_memory() { mem } else { return Ok(()) };
472472
// See current_memory() why this assert is here
473473
let _: () = const { assert!(mem::size_of::<T>() % mem::align_of::<T>() == 0) };
474-
475-
// If shrinking to 0, deallocate the buffer. We don't reach this point
476-
// for the T::IS_ZST case since current_memory() will have returned
477-
// None.
478-
if cap == 0 {
479-
unsafe { self.alloc.deallocate(ptr, layout) };
480-
self.ptr = Unique::dangling();
481-
self.cap = 0;
482-
} else {
483-
let ptr = unsafe {
484-
// `Layout::array` cannot overflow here because it would have
485-
// overflowed earlier when capacity was larger.
486-
let new_size = mem::size_of::<T>().unchecked_mul(cap);
487-
let new_layout = Layout::from_size_align_unchecked(new_size, layout.align());
488-
self.alloc
489-
.shrink(ptr, layout, new_layout)
490-
.map_err(|_| AllocError { layout: new_layout, non_exhaustive: () })?
491-
};
492-
self.set_ptr_and_cap(ptr, cap);
493-
}
474+
let ptr = unsafe {
475+
// `Layout::array` cannot overflow here because it would have
476+
// overflowed earlier when capacity was larger.
477+
let new_size = mem::size_of::<T>().unchecked_mul(cap);
478+
let new_layout = Layout::from_size_align_unchecked(new_size, layout.align());
479+
self.alloc
480+
.shrink(ptr, layout, new_layout)
481+
.map_err(|_| AllocError { layout: new_layout, non_exhaustive: () })?
482+
};
483+
self.set_ptr_and_cap(ptr, cap);
494484
Ok(())
495485
}
496486
}

rust/alloc/vec/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ mod spec_extend;
216216
///
217217
/// # Indexing
218218
///
219-
/// The `Vec` type allows access to values by index, because it implements the
219+
/// The `Vec` type allows to access values by index, because it implements the
220220
/// [`Index`] trait. An example will be more explicit:
221221
///
222222
/// ```
@@ -3263,7 +3263,7 @@ impl<T, A: Allocator> Vec<T, A> {
32633263
/// [`copy_from_slice`]: slice::copy_from_slice
32643264
#[cfg(not(no_global_oom_handling))]
32653265
#[stable(feature = "extend_ref", since = "1.2.0")]
3266-
impl<'a, T: Copy + 'a, A: Allocator> Extend<&'a T> for Vec<T, A> {
3266+
impl<'a, T: Copy + 'a, A: Allocator + 'a> Extend<&'a T> for Vec<T, A> {
32673267
fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I) {
32683268
self.spec_extend(iter.into_iter())
32693269
}

rust/alloc/vec/spec_extend.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl<T, A: Allocator> TrySpecExtend<T, IntoIter<T>> for Vec<T, A> {
7777
}
7878

7979
#[cfg(not(no_global_oom_handling))]
80-
impl<'a, T: 'a, I, A: Allocator> SpecExtend<&'a T, I> for Vec<T, A>
80+
impl<'a, T: 'a, I, A: Allocator + 'a> SpecExtend<&'a T, I> for Vec<T, A>
8181
where
8282
I: Iterator<Item = &'a T>,
8383
T: Clone,
@@ -87,7 +87,7 @@ where
8787
}
8888
}
8989

90-
impl<'a, T: 'a, I, A: Allocator> TrySpecExtend<&'a T, I> for Vec<T, A>
90+
impl<'a, T: 'a, I, A: Allocator + 'a> TrySpecExtend<&'a T, I> for Vec<T, A>
9191
where
9292
I: Iterator<Item = &'a T>,
9393
T: Clone,
@@ -98,7 +98,7 @@ where
9898
}
9999

100100
#[cfg(not(no_global_oom_handling))]
101-
impl<'a, T: 'a, A: Allocator> SpecExtend<&'a T, slice::Iter<'a, T>> for Vec<T, A>
101+
impl<'a, T: 'a, A: Allocator + 'a> SpecExtend<&'a T, slice::Iter<'a, T>> for Vec<T, A>
102102
where
103103
T: Copy,
104104
{
@@ -108,7 +108,7 @@ where
108108
}
109109
}
110110

111-
impl<'a, T: 'a, A: Allocator> TrySpecExtend<&'a T, slice::Iter<'a, T>> for Vec<T, A>
111+
impl<'a, T: 'a, A: Allocator + 'a> TrySpecExtend<&'a T, slice::Iter<'a, T>> for Vec<T, A>
112112
where
113113
T: Copy,
114114
{

rust/compiler_builtins.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
//! [`compiler_builtins`]: https://github.com/rust-lang/compiler-builtins
2020
//! [`compiler-rt`]: https://compiler-rt.llvm.org/
2121
22-
#![allow(internal_features)]
2322
#![feature(compiler_builtins)]
2423
#![compiler_builtins]
2524
#![no_builtins]

scripts/min-tool-version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ llvm)
3131
fi
3232
;;
3333
rustc)
34-
echo 1.73.0
34+
echo 1.72.1
3535
;;
3636
bindgen)
3737
echo 0.65.1

0 commit comments

Comments
 (0)