Skip to content

Commit c4b483a

Browse files
committed
rust: upgrade to Rust 1.61.0
Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 37bfea1 commit c4b483a

File tree

16 files changed

+122
-77
lines changed

16 files changed

+122
-77
lines changed

.github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
jobs:
88
ci:
99
runs-on: ubuntu-20.04
10-
container: ghcr.io/rust-for-linux/ci:Rust-1.60.0
10+
container: ghcr.io/rust-for-linux/ci:Rust-1.61.0
1111
timeout-minutes: 20
1212

1313
strategy:

Documentation/process/changes.rst

+1-1
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.60.0 rustc --version
34+
Rust (optional) 1.61.0 rustc --version
3535
bindgen (optional) 0.56.0 bindgen --version
3636
GNU make 3.81 make --version
3737
binutils 2.23 ld -v

rust/alloc/alloc.rs

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

19+
use core::marker::Destruct;
20+
1921
#[cfg(test)]
2022
mod tests;
2123

@@ -326,12 +328,16 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
326328
#[cfg_attr(not(test), lang = "box_free")]
327329
#[inline]
328330
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
331+
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
329332
// This signature has to be the same as `Box`, otherwise an ICE will happen.
330333
// When an additional parameter to `Box` is added (like `A: Allocator`), this has to be added here as
331334
// well.
332335
// For example if `Box` is changed to `struct Box<T: ?Sized, A: Allocator>(Unique<T>, A)`,
333336
// this function has to be changed to `fn box_free<T: ?Sized, A: Allocator>(Unique<T>, A)` as well.
334-
pub(crate) const unsafe fn box_free<T: ?Sized, A: ~const Allocator + ~const Drop>(
337+
pub(crate) const unsafe fn box_free<
338+
T: ?Sized,
339+
A: ~const Allocator + ~const Drop + ~const Destruct,
340+
>(
335341
ptr: Unique<T>,
336342
alloc: A,
337343
) {
@@ -399,7 +405,7 @@ pub mod __alloc_error_handler {
399405
// if there is no `#[alloc_error_handler]`
400406
#[rustc_std_internal_symbol]
401407
pub unsafe extern "C-unwind" fn __rdl_oom(size: usize, _align: usize) -> ! {
402-
panic!("memory allocation of {} bytes failed", size)
408+
panic!("memory allocation of {size} bytes failed")
403409
}
404410

405411
// if there is an `#[alloc_error_handler]`

rust/alloc/borrow.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ where
163163
/// let readonly = [1, 2];
164164
/// let borrowed = Items::new((&readonly[..]).into());
165165
/// match borrowed {
166-
/// Items { values: Cow::Borrowed(b) } => println!("borrowed {:?}", b),
166+
/// Items { values: Cow::Borrowed(b) } => println!("borrowed {b:?}"),
167167
/// _ => panic!("expect borrowed value"),
168168
/// }
169169
///
@@ -333,6 +333,7 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
333333

334334
#[stable(feature = "rust1", since = "1.0.0")]
335335
#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
336+
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
336337
impl<B: ?Sized + ToOwned> const Deref for Cow<'_, B>
337338
where
338339
B::Owned: ~const Borrow<B>,

rust/alloc/boxed.rs

+24-16
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
//! }
3434
//!
3535
//! let list: List<i32> = List::Cons(1, Box::new(List::Cons(2, Box::new(List::Nil))));
36-
//! println!("{:?}", list);
36+
//! println!("{list:?}");
3737
//! ```
3838
//!
3939
//! This will print `Cons(1, Cons(2, Nil))`.
@@ -145,7 +145,7 @@ use core::hash::{Hash, Hasher};
145145
#[cfg(not(no_global_oom_handling))]
146146
use core::iter::FromIterator;
147147
use core::iter::{FusedIterator, Iterator};
148-
use core::marker::{Unpin, Unsize};
148+
use core::marker::{Destruct, Unpin, Unsize};
149149
use core::mem;
150150
use core::ops::{
151151
CoerceUnsized, Deref, DerefMut, DispatchFromDyn, Generator, GeneratorState, Receiver,
@@ -351,9 +351,10 @@ impl<T, A: Allocator> Box<T, A> {
351351
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
352352
#[must_use]
353353
#[inline]
354+
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
354355
pub const fn new_in(x: T, alloc: A) -> Self
355356
where
356-
A: ~const Allocator + ~const Drop,
357+
A: ~const Allocator + ~const Drop + ~const Destruct,
357358
{
358359
let mut boxed = Self::new_uninit_in(alloc);
359360
unsafe {
@@ -380,10 +381,11 @@ impl<T, A: Allocator> Box<T, A> {
380381
#[unstable(feature = "allocator_api", issue = "32838")]
381382
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
382383
#[inline]
384+
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
383385
pub const fn try_new_in(x: T, alloc: A) -> Result<Self, AllocError>
384386
where
385-
T: ~const Drop,
386-
A: ~const Allocator + ~const Drop,
387+
T: ~const Drop + ~const Destruct,
388+
A: ~const Allocator + ~const Drop + ~const Destruct,
387389
{
388390
let mut boxed = Self::try_new_uninit_in(alloc)?;
389391
unsafe {
@@ -417,9 +419,10 @@ impl<T, A: Allocator> Box<T, A> {
417419
#[cfg(not(no_global_oom_handling))]
418420
#[must_use]
419421
// #[unstable(feature = "new_uninit", issue = "63291")]
422+
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
420423
pub const fn new_uninit_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
421424
where
422-
A: ~const Allocator + ~const Drop,
425+
A: ~const Allocator + ~const Drop + ~const Destruct,
423426
{
424427
let layout = Layout::new::<mem::MaybeUninit<T>>();
425428
// NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
@@ -455,9 +458,10 @@ impl<T, A: Allocator> Box<T, A> {
455458
#[unstable(feature = "allocator_api", issue = "32838")]
456459
// #[unstable(feature = "new_uninit", issue = "63291")]
457460
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
461+
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
458462
pub const fn try_new_uninit_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
459463
where
460-
A: ~const Allocator + ~const Drop,
464+
A: ~const Allocator + ~const Drop + ~const Destruct,
461465
{
462466
let layout = Layout::new::<mem::MaybeUninit<T>>();
463467
let ptr = alloc.allocate(layout)?.cast();
@@ -489,9 +493,10 @@ impl<T, A: Allocator> Box<T, A> {
489493
#[cfg(not(no_global_oom_handling))]
490494
// #[unstable(feature = "new_uninit", issue = "63291")]
491495
#[must_use]
496+
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
492497
pub const fn new_zeroed_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
493498
where
494-
A: ~const Allocator + ~const Drop,
499+
A: ~const Allocator + ~const Drop + ~const Destruct,
495500
{
496501
let layout = Layout::new::<mem::MaybeUninit<T>>();
497502
// NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
@@ -527,9 +532,10 @@ impl<T, A: Allocator> Box<T, A> {
527532
#[unstable(feature = "allocator_api", issue = "32838")]
528533
// #[unstable(feature = "new_uninit", issue = "63291")]
529534
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
535+
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
530536
pub const fn try_new_zeroed_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
531537
where
532-
A: ~const Allocator + ~const Drop,
538+
A: ~const Allocator + ~const Drop + ~const Destruct,
533539
{
534540
let layout = Layout::new::<mem::MaybeUninit<T>>();
535541
let ptr = alloc.allocate_zeroed(layout)?.cast();
@@ -543,9 +549,10 @@ impl<T, A: Allocator> Box<T, A> {
543549
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
544550
#[must_use]
545551
#[inline(always)]
552+
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
546553
pub const fn pin_in(x: T, alloc: A) -> Pin<Self>
547554
where
548-
A: 'static + ~const Allocator + ~const Drop,
555+
A: 'static + ~const Allocator + ~const Drop + ~const Destruct,
549556
{
550557
Self::into_pin(Self::new_in(x, alloc))
551558
}
@@ -574,9 +581,10 @@ impl<T, A: Allocator> Box<T, A> {
574581
#[unstable(feature = "box_into_inner", issue = "80437")]
575582
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
576583
#[inline]
584+
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
577585
pub const fn into_inner(boxed: Self) -> T
578586
where
579-
Self: ~const Drop,
587+
Self: ~const Drop + ~const Destruct,
580588
{
581589
*boxed
582590
}
@@ -1409,7 +1417,7 @@ impl<T: Copy> From<&[T]> for Box<[T]> {
14091417
/// let slice: &[u8] = &[104, 101, 108, 108, 111];
14101418
/// let boxed_slice: Box<[u8]> = Box::from(slice);
14111419
///
1412-
/// println!("{:?}", boxed_slice);
1420+
/// println!("{boxed_slice:?}");
14131421
/// ```
14141422
fn from(slice: &[T]) -> Box<[T]> {
14151423
let len = slice.len();
@@ -1451,7 +1459,7 @@ impl From<&str> for Box<str> {
14511459
///
14521460
/// ```rust
14531461
/// let boxed: Box<str> = Box::from("hello");
1454-
/// println!("{}", boxed);
1462+
/// println!("{boxed}");
14551463
/// ```
14561464
#[inline]
14571465
fn from(s: &str) -> Box<str> {
@@ -1476,14 +1484,14 @@ impl From<Cow<'_, str>> for Box<str> {
14761484
///
14771485
/// let unboxed = Cow::Borrowed("hello");
14781486
/// let boxed: Box<str> = Box::from(unboxed);
1479-
/// println!("{}", boxed);
1487+
/// println!("{boxed}");
14801488
/// ```
14811489
///
14821490
/// ```rust
14831491
/// # use std::borrow::Cow;
14841492
/// let unboxed = Cow::Owned("hello".to_string());
14851493
/// let boxed: Box<str> = Box::from(unboxed);
1486-
/// println!("{}", boxed);
1494+
/// println!("{boxed}");
14871495
/// ```
14881496
#[inline]
14891497
fn from(cow: Cow<'_, str>) -> Box<str> {
@@ -1530,7 +1538,7 @@ impl<T, const N: usize> From<[T; N]> for Box<[T]> {
15301538
///
15311539
/// ```rust
15321540
/// let boxed: Box<[u8]> = Box::from([4, 2]);
1533-
/// println!("{:?}", boxed);
1541+
/// println!("{boxed:?}");
15341542
/// ```
15351543
fn from(array: [T; N]) -> Box<[T]> {
15361544
box array

rust/alloc/fmt.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,9 @@
418418
//! fn main() {
419419
//! let myvector = Vector2D { x: 3, y: 4 };
420420
//!
421-
//! println!("{}", myvector); // => "(3, 4)"
422-
//! println!("{:?}", myvector); // => "Vector2D {x: 3, y:4}"
423-
//! println!("{:10.3b}", myvector); // => " 5.000"
421+
//! println!("{myvector}"); // => "(3, 4)"
422+
//! println!("{myvector:?}"); // => "Vector2D {x: 3, y:4}"
423+
//! println!("{myvector:10.3b}"); // => " 5.000"
424424
//! }
425425
//! ```
426426
//!

rust/alloc/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
#![feature(slice_ptr_len)]
130130
#![feature(slice_range)]
131131
#![feature(str_internals)]
132+
#![feature(strict_provenance)]
132133
#![feature(trusted_len)]
133134
#![feature(trusted_random_access)]
134135
#![feature(try_trait_v2)]
@@ -141,9 +142,8 @@
141142
#![feature(associated_type_bounds)]
142143
#![feature(box_syntax)]
143144
#![feature(cfg_sanitize)]
144-
#![cfg_attr(bootstrap, feature(cfg_target_has_atomic))]
145145
#![feature(const_deref)]
146-
#![feature(const_fn_trait_bound)]
146+
#![cfg_attr(bootstrap, feature(const_fn_trait_bound))]
147147
#![feature(const_mut_refs)]
148148
#![feature(const_ptr_write)]
149149
#![feature(const_precise_live_drops)]

rust/alloc/raw_vec.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,7 @@ impl<T, A: Allocator> RawVec<T, A> {
276276
// We have an allocated chunk of memory, so we can bypass runtime
277277
// checks to get our current layout.
278278
unsafe {
279-
let align = mem::align_of::<T>();
280-
let size = mem::size_of::<T>() * self.cap;
281-
let layout = Layout::from_size_align_unchecked(size, align);
279+
let layout = Layout::array::<T>(self.cap).unwrap_unchecked();
282280
Some((self.ptr.cast().into(), layout))
283281
}
284282
}
@@ -475,10 +473,11 @@ impl<T, A: Allocator> RawVec<T, A> {
475473
assert!(cap <= self.capacity(), "Tried to shrink to a larger capacity");
476474

477475
let (ptr, layout) = if let Some(mem) = self.current_memory() { mem } else { return Ok(()) };
478-
let new_size = cap * mem::size_of::<T>();
479476

480477
let ptr = unsafe {
481-
let new_layout = Layout::from_size_align_unchecked(new_size, layout.align());
478+
// `Layout::array` cannot overflow here because it would have
479+
// overflowed earlier when capacity was larger.
480+
let new_layout = Layout::array::<T>(cap).unwrap_unchecked();
482481
self.alloc
483482
.shrink(ptr, layout, new_layout)
484483
.map_err(|_| AllocError { layout: new_layout, non_exhaustive: () })?

0 commit comments

Comments
 (0)