Skip to content

Commit b4bc918

Browse files
committed
rust: 1.71.0 compat hacks
Signed-off-by: Hector Martin <[email protected]>
1 parent eba3fc5 commit b4bc918

9 files changed

Lines changed: 47 additions & 67 deletions

File tree

rust/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ rust-analyzer:
378378
$(RUST_LIB_SRC) > $(objtree)/rust-project.json
379379

380380
redirect-intrinsics = \
381-
__eqsf2 __gesf2 __lesf2 __nesf2 __unordsf2 \
382-
__unorddf2 \
381+
__addsf3 __eqsf2 __gesf2 __lesf2 __ltsf2 __mulsf3 __nesf2 __unordsf2 \
382+
__adddf3 __ledf2 __ltdf2 __muldf3 __unorddf2 \
383383
__muloti4 __multi3 \
384384
__udivmodti4 __udivti3 __umodti3
385385

rust/alloc/alloc.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ use core::ptr::{self, NonNull};
1616
#[doc(inline)]
1717
pub use core::alloc::*;
1818

19-
use core::marker::Destruct;
20-
2119
#[cfg(test)]
2220
mod tests;
2321

@@ -333,13 +331,12 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
333331

334332
#[cfg_attr(not(test), lang = "box_free")]
335333
#[inline]
336-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
337334
// This signature has to be the same as `Box`, otherwise an ICE will happen.
338335
// When an additional parameter to `Box` is added (like `A: Allocator`), this has to be added here as
339336
// well.
340337
// For example if `Box` is changed to `struct Box<T: ?Sized, A: Allocator>(Unique<T>, A)`,
341338
// this function has to be changed to `fn box_free<T: ?Sized, A: Allocator>(Unique<T>, A)` as well.
342-
pub(crate) const unsafe fn box_free<T: ?Sized, A: ~const Allocator + ~const Destruct>(
339+
pub(crate) unsafe fn box_free<T: ?Sized, A: Allocator>(
343340
ptr: Unique<T>,
344341
alloc: A,
345342
) {

rust/alloc/boxed.rs

Lines changed: 30 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ use core::hash::{Hash, Hasher};
161161
use core::iter::FromIterator;
162162
use core::iter::{FusedIterator, Iterator};
163163
use core::marker::Tuple;
164-
use core::marker::{Destruct, Unpin, Unsize};
164+
use core::marker::{Unpin, Unsize};
165165
use core::mem;
166166
use core::ops::{
167167
CoerceUnsized, Deref, DerefMut, DispatchFromDyn, Generator, GeneratorState, Receiver,
@@ -381,12 +381,11 @@ impl<T, A: Allocator> Box<T, A> {
381381
/// ```
382382
#[cfg(not(no_global_oom_handling))]
383383
#[unstable(feature = "allocator_api", issue = "32838")]
384-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
385384
#[must_use]
386385
#[inline]
387-
pub const fn new_in(x: T, alloc: A) -> Self
386+
pub fn new_in(x: T, alloc: A) -> Self
388387
where
389-
A: ~const Allocator + ~const Destruct,
388+
A: Allocator,
390389
{
391390
let mut boxed = Self::new_uninit_in(alloc);
392391
unsafe {
@@ -411,12 +410,10 @@ impl<T, A: Allocator> Box<T, A> {
411410
/// # Ok::<(), std::alloc::AllocError>(())
412411
/// ```
413412
#[unstable(feature = "allocator_api", issue = "32838")]
414-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
415413
#[inline]
416-
pub const fn try_new_in(x: T, alloc: A) -> Result<Self, AllocError>
414+
pub fn try_new_in(x: T, alloc: A) -> Result<Self, AllocError>
417415
where
418-
T: ~const Destruct,
419-
A: ~const Allocator + ~const Destruct,
416+
A: Allocator,
420417
{
421418
let mut boxed = Self::try_new_uninit_in(alloc)?;
422419
unsafe {
@@ -446,13 +443,12 @@ impl<T, A: Allocator> Box<T, A> {
446443
/// assert_eq!(*five, 5)
447444
/// ```
448445
#[unstable(feature = "allocator_api", issue = "32838")]
449-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
450446
#[cfg(not(no_global_oom_handling))]
451447
#[must_use]
452448
// #[unstable(feature = "new_uninit", issue = "63291")]
453-
pub const fn new_uninit_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
449+
pub fn new_uninit_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
454450
where
455-
A: ~const Allocator + ~const Destruct,
451+
A: Allocator,
456452
{
457453
let layout = Layout::new::<mem::MaybeUninit<T>>();
458454
// NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
@@ -487,10 +483,9 @@ impl<T, A: Allocator> Box<T, A> {
487483
/// ```
488484
#[unstable(feature = "allocator_api", issue = "32838")]
489485
// #[unstable(feature = "new_uninit", issue = "63291")]
490-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
491-
pub const fn try_new_uninit_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
486+
pub fn try_new_uninit_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
492487
where
493-
A: ~const Allocator + ~const Destruct,
488+
A: Allocator,
494489
{
495490
let layout = Layout::new::<mem::MaybeUninit<T>>();
496491
let ptr = alloc.allocate(layout)?.cast();
@@ -518,13 +513,12 @@ impl<T, A: Allocator> Box<T, A> {
518513
///
519514
/// [zeroed]: mem::MaybeUninit::zeroed
520515
#[unstable(feature = "allocator_api", issue = "32838")]
521-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
522516
#[cfg(not(no_global_oom_handling))]
523517
// #[unstable(feature = "new_uninit", issue = "63291")]
524518
#[must_use]
525-
pub const fn new_zeroed_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
519+
pub fn new_zeroed_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
526520
where
527-
A: ~const Allocator + ~const Destruct,
521+
A: Allocator,
528522
{
529523
let layout = Layout::new::<mem::MaybeUninit<T>>();
530524
// NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
@@ -559,10 +553,9 @@ impl<T, A: Allocator> Box<T, A> {
559553
/// [zeroed]: mem::MaybeUninit::zeroed
560554
#[unstable(feature = "allocator_api", issue = "32838")]
561555
// #[unstable(feature = "new_uninit", issue = "63291")]
562-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
563-
pub const fn try_new_zeroed_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
556+
pub fn try_new_zeroed_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
564557
where
565-
A: ~const Allocator + ~const Destruct,
558+
A: Allocator,
566559
{
567560
let layout = Layout::new::<mem::MaybeUninit<T>>();
568561
let ptr = alloc.allocate_zeroed(layout)?.cast();
@@ -578,12 +571,11 @@ impl<T, A: Allocator> Box<T, A> {
578571
/// construct a (pinned) `Box` in a different way than with [`Box::new_in`].
579572
#[cfg(not(no_global_oom_handling))]
580573
#[unstable(feature = "allocator_api", issue = "32838")]
581-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
582574
#[must_use]
583575
#[inline(always)]
584-
pub const fn pin_in(x: T, alloc: A) -> Pin<Self>
576+
pub fn pin_in(x: T, alloc: A) -> Pin<Self>
585577
where
586-
A: 'static + ~const Allocator + ~const Destruct,
578+
A: 'static + Allocator,
587579
{
588580
Self::into_pin(Self::new_in(x, alloc))
589581
}
@@ -592,8 +584,7 @@ impl<T, A: Allocator> Box<T, A> {
592584
///
593585
/// This conversion does not allocate on the heap and happens in place.
594586
#[unstable(feature = "box_into_boxed_slice", issue = "71582")]
595-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
596-
pub const fn into_boxed_slice(boxed: Self) -> Box<[T], A> {
587+
pub fn into_boxed_slice(boxed: Self) -> Box<[T], A> {
597588
let (raw, alloc) = Box::into_raw_with_allocator(boxed);
598589
unsafe { Box::from_raw_in(raw as *mut [T; 1], alloc) }
599590
}
@@ -610,11 +601,8 @@ impl<T, A: Allocator> Box<T, A> {
610601
/// assert_eq!(Box::into_inner(c), 5);
611602
/// ```
612603
#[unstable(feature = "box_into_inner", issue = "80437")]
613-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
614604
#[inline]
615-
pub const fn into_inner(boxed: Self) -> T
616-
where
617-
Self: ~const Destruct,
605+
pub fn into_inner(boxed: Self) -> T
618606
{
619607
*boxed
620608
}
@@ -829,9 +817,8 @@ impl<T, A: Allocator> Box<mem::MaybeUninit<T>, A> {
829817
/// assert_eq!(*five, 5)
830818
/// ```
831819
#[unstable(feature = "new_uninit", issue = "63291")]
832-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
833820
#[inline]
834-
pub const unsafe fn assume_init(self) -> Box<T, A> {
821+
pub unsafe fn assume_init(self) -> Box<T, A> {
835822
let (raw, alloc) = Box::into_raw_with_allocator(self);
836823
unsafe { Box::from_raw_in(raw as *mut T, alloc) }
837824
}
@@ -864,9 +851,8 @@ impl<T, A: Allocator> Box<mem::MaybeUninit<T>, A> {
864851
/// }
865852
/// ```
866853
#[unstable(feature = "new_uninit", issue = "63291")]
867-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
868854
#[inline]
869-
pub const fn write(mut boxed: Self, value: T) -> Box<T, A> {
855+
pub fn write(mut boxed: Self, value: T) -> Box<T, A> {
870856
unsafe {
871857
(*boxed).write(value);
872858
boxed.assume_init()
@@ -1012,9 +998,8 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
1012998
/// [memory layout]: self#memory-layout
1013999
/// [`Layout`]: crate::Layout
10141000
#[unstable(feature = "allocator_api", issue = "32838")]
1015-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
10161001
#[inline]
1017-
pub const unsafe fn from_raw_in(raw: *mut T, alloc: A) -> Self {
1002+
pub unsafe fn from_raw_in(raw: *mut T, alloc: A) -> Self {
10181003
Box(unsafe { Unique::new_unchecked(raw) }, alloc)
10191004
}
10201005

@@ -1110,9 +1095,8 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
11101095
///
11111096
/// [memory layout]: self#memory-layout
11121097
#[unstable(feature = "allocator_api", issue = "32838")]
1113-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
11141098
#[inline]
1115-
pub const fn into_raw_with_allocator(b: Self) -> (*mut T, A) {
1099+
pub fn into_raw_with_allocator(b: Self) -> (*mut T, A) {
11161100
let (leaked, alloc) = Box::into_unique(b);
11171101
(leaked.as_ptr(), alloc)
11181102
}
@@ -1122,10 +1106,9 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
11221106
issue = "none",
11231107
reason = "use `Box::leak(b).into()` or `Unique::from(Box::leak(b))` instead"
11241108
)]
1125-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
11261109
#[inline]
11271110
#[doc(hidden)]
1128-
pub const fn into_unique(b: Self) -> (Unique<T>, A) {
1111+
pub fn into_unique(b: Self) -> (Unique<T>, A) {
11291112
// Box is recognized as a "unique pointer" by Stacked Borrows, but internally it is a
11301113
// raw pointer for the type system. Turning it directly into a raw pointer would not be
11311114
// recognized as "releasing" the unique pointer to permit aliased raw accesses,
@@ -1141,9 +1124,8 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
11411124
/// to call it as `Box::allocator(&b)` instead of `b.allocator()`. This
11421125
/// is so that there is no conflict with a method on the inner type.
11431126
#[unstable(feature = "allocator_api", issue = "32838")]
1144-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
11451127
#[inline]
1146-
pub const fn allocator(b: &Self) -> &A {
1128+
pub fn allocator(b: &Self) -> &A {
11471129
&b.1
11481130
}
11491131

@@ -1183,9 +1165,8 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
11831165
/// assert_eq!(*static_ref, [4, 2, 3]);
11841166
/// ```
11851167
#[stable(feature = "box_leak", since = "1.26.0")]
1186-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
11871168
#[inline]
1188-
pub const fn leak<'a>(b: Self) -> &'a mut T
1169+
pub fn leak<'a>(b: Self) -> &'a mut T
11891170
where
11901171
A: 'a,
11911172
{
@@ -1223,8 +1204,7 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
12231204
/// let bar = Pin::from(foo);
12241205
/// ```
12251206
#[stable(feature = "box_into_pin", since = "1.63.0")]
1226-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
1227-
pub const fn into_pin(boxed: Self) -> Pin<Self>
1207+
pub fn into_pin(boxed: Self) -> Pin<Self>
12281208
where
12291209
A: 'static,
12301210
{
@@ -1254,8 +1234,7 @@ impl<T: Default> Default for Box<T> {
12541234

12551235
#[cfg(not(no_global_oom_handling))]
12561236
#[stable(feature = "rust1", since = "1.0.0")]
1257-
#[rustc_const_unstable(feature = "const_default_impls", issue = "87864")]
1258-
impl<T> const Default for Box<[T]> {
1237+
impl<T> Default for Box<[T]> {
12591238
fn default() -> Self {
12601239
let ptr: Unique<[T]> = Unique::<[T; 0]>::dangling();
12611240
Box(ptr, Global)
@@ -1264,8 +1243,7 @@ impl<T> const Default for Box<[T]> {
12641243

12651244
#[cfg(not(no_global_oom_handling))]
12661245
#[stable(feature = "default_box_extra", since = "1.17.0")]
1267-
#[rustc_const_unstable(feature = "const_default_impls", issue = "87864")]
1268-
impl const Default for Box<str> {
1246+
impl Default for Box<str> {
12691247
fn default() -> Self {
12701248
// SAFETY: This is the same as `Unique::cast<U>` but with an unsized `U = str`.
12711249
let ptr: Unique<str> = unsafe {
@@ -1461,8 +1439,7 @@ impl<T> From<T> for Box<T> {
14611439
}
14621440

14631441
#[stable(feature = "pin", since = "1.33.0")]
1464-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
1465-
impl<T: ?Sized, A: Allocator> const From<Box<T, A>> for Pin<Box<T, A>>
1442+
impl<T: ?Sized, A: Allocator> From<Box<T, A>> for Pin<Box<T, A>>
14661443
where
14671444
A: 'static,
14681445
{
@@ -1899,8 +1876,7 @@ impl<T: ?Sized, A: Allocator> fmt::Pointer for Box<T, A> {
18991876
}
19001877

19011878
#[stable(feature = "rust1", since = "1.0.0")]
1902-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
1903-
impl<T: ?Sized, A: Allocator> const Deref for Box<T, A> {
1879+
impl<T: ?Sized, A: Allocator> Deref for Box<T, A> {
19041880
type Target = T;
19051881

19061882
fn deref(&self) -> &T {
@@ -1909,8 +1885,7 @@ impl<T: ?Sized, A: Allocator> const Deref for Box<T, A> {
19091885
}
19101886

19111887
#[stable(feature = "rust1", since = "1.0.0")]
1912-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
1913-
impl<T: ?Sized, A: Allocator> const DerefMut for Box<T, A> {
1888+
impl<T: ?Sized, A: Allocator> DerefMut for Box<T, A> {
19141889
fn deref_mut(&mut self) -> &mut T {
19151890
&mut **self
19161891
}

rust/alloc/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,8 @@
101101
#![feature(async_iterator)]
102102
#![feature(coerce_unsized)]
103103
#![cfg_attr(not(no_global_oom_handling), feature(const_alloc_error))]
104-
#![feature(const_box)]
105104
#![cfg_attr(not(no_global_oom_handling), feature(const_btree_len))]
106105
#![cfg_attr(not(no_borrow), feature(const_cow_is_borrowed))]
107-
#![feature(const_convert)]
108106
#![feature(const_size_of_val)]
109107
#![feature(const_align_of_val)]
110108
#![feature(const_ptr_read)]
@@ -170,7 +168,6 @@
170168
#![feature(allow_internal_unstable)]
171169
#![feature(associated_type_bounds)]
172170
#![feature(cfg_sanitize)]
173-
#![feature(const_deref)]
174171
#![feature(const_mut_refs)]
175172
#![feature(const_ptr_write)]
176173
#![feature(const_precise_live_drops)]

rust/alloc/vec/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3365,8 +3365,7 @@ unsafe impl<#[may_dangle] T, A: Allocator> Drop for Vec<T, A> {
33653365
}
33663366

33673367
#[stable(feature = "rust1", since = "1.0.0")]
3368-
#[rustc_const_unstable(feature = "const_default_impls", issue = "87864")]
3369-
impl<T> const Default for Vec<T> {
3368+
impl<T> Default for Vec<T> {
33703369
/// Creates an empty `Vec<T>`.
33713370
///
33723371
/// The vector will not allocate until elements are pushed onto it.

rust/compiler_builtins.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,21 @@ macro_rules! define_panicking_intrinsics(
3737
);
3838

3939
define_panicking_intrinsics!("`f32` should not be used", {
40+
__addsf3,
4041
__eqsf2,
4142
__gesf2,
4243
__lesf2,
44+
__ltsf2,
45+
__mulsf3,
4346
__nesf2,
4447
__unordsf2,
4548
});
4649

4750
define_panicking_intrinsics!("`f64` should not be used", {
51+
__adddf3,
52+
__ledf2,
53+
__ltdf2,
54+
__muldf3,
4855
__unorddf2,
4956
});
5057

rust/kernel/allocator.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,19 @@ static ALLOCATOR: KernelAllocator = KernelAllocator;
3131
// let's generate them ourselves instead.
3232
//
3333
// Note that `#[no_mangle]` implies exported too, nowadays.
34+
#[cfg(not(version("1.71")))]
3435
#[no_mangle]
3536
fn __rust_alloc(size: usize, _align: usize) -> *mut u8 {
3637
unsafe { bindings::krealloc(core::ptr::null(), size, bindings::GFP_KERNEL) as *mut u8 }
3738
}
3839

40+
#[cfg(not(version("1.71")))]
3941
#[no_mangle]
4042
fn __rust_dealloc(ptr: *mut u8, _size: usize, _align: usize) {
4143
unsafe { bindings::kfree(ptr as *const core::ffi::c_void) };
4244
}
4345

46+
#[cfg(not(version("1.71")))]
4447
#[no_mangle]
4548
fn __rust_realloc(ptr: *mut u8, _old_size: usize, _align: usize, new_size: usize) -> *mut u8 {
4649
unsafe {
@@ -52,6 +55,7 @@ fn __rust_realloc(ptr: *mut u8, _old_size: usize, _align: usize, new_size: usize
5255
}
5356
}
5457

58+
#[cfg(not(version("1.71")))]
5559
#[no_mangle]
5660
fn __rust_alloc_zeroed(size: usize, _align: usize) -> *mut u8 {
5761
unsafe {

rust/kernel/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ pub struct IdTable<'a, T: RawDeviceId, U> {
221221
_p: PhantomData<&'a U>,
222222
}
223223

224-
impl<T: RawDeviceId, U> const AsRef<T::RawType> for IdTable<'_, T, U> {
224+
impl<T: RawDeviceId, U> AsRef<T::RawType> for IdTable<'_, T, U> {
225225
fn as_ref(&self) -> &T::RawType {
226226
self.first
227227
}

0 commit comments

Comments
 (0)