Skip to content

Commit 4297971

Browse files
authored
Merge pull request torvalds#799 from ojeda/rust-1.62.0
Rust 1.62.0
2 parents abe843f + 7e956ca commit 4297971

File tree

24 files changed

+1874
-160
lines changed

24 files changed

+1874
-160
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
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.61.0
10+
container: ghcr.io/rust-for-linux/ci:Rust-1.62.0
1111
timeout-minutes: 20
1212

1313
strategy:

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.61.0 rustc --version
34+
Rust (optional) 1.62.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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,16 +328,12 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
328328
#[cfg_attr(not(test), lang = "box_free")]
329329
#[inline]
330330
#[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
332331
// This signature has to be the same as `Box`, otherwise an ICE will happen.
333332
// When an additional parameter to `Box` is added (like `A: Allocator`), this has to be added here as
334333
// well.
335334
// For example if `Box` is changed to `struct Box<T: ?Sized, A: Allocator>(Unique<T>, A)`,
336335
// this function has to be changed to `fn box_free<T: ?Sized, A: Allocator>(Unique<T>, A)` as well.
337-
pub(crate) const unsafe fn box_free<
338-
T: ?Sized,
339-
A: ~const Allocator + ~const Drop + ~const Destruct,
340-
>(
336+
pub(crate) const unsafe fn box_free<T: ?Sized, A: ~const Allocator + ~const Destruct>(
341337
ptr: Unique<T>,
342338
alloc: A,
343339
) {
@@ -393,7 +389,7 @@ pub const fn handle_alloc_error(layout: Layout) -> ! {
393389
#[cfg(all(not(no_global_oom_handling), test))]
394390
pub use std::alloc::handle_alloc_error;
395391

396-
#[cfg(all(not(no_global_oom_handling), not(any(target_os = "hermit", test))))]
392+
#[cfg(all(not(no_global_oom_handling), not(test)))]
397393
#[doc(hidden)]
398394
#[allow(unused_attributes)]
399395
#[unstable(feature = "alloc_internals", issue = "none")]

rust/alloc/borrow.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,7 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
294294
///
295295
/// # Examples
296296
///
297-
/// Calling `into_owned` on a `Cow::Borrowed` clones the underlying data
298-
/// and becomes a `Cow::Owned`:
297+
/// Calling `into_owned` on a `Cow::Borrowed` returns a clone of the borrowed data:
299298
///
300299
/// ```
301300
/// use std::borrow::Cow;
@@ -309,7 +308,8 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
309308
/// );
310309
/// ```
311310
///
312-
/// Calling `into_owned` on a `Cow::Owned` is a no-op:
311+
/// Calling `into_owned` on a `Cow::Owned` returns the owned data. The data is moved out of the
312+
/// `Cow` without being cloned.
313313
///
314314
/// ```
315315
/// use std::borrow::Cow;
@@ -333,7 +333,6 @@ 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
337336
impl<B: ?Sized + ToOwned> const Deref for Cow<'_, B>
338337
where
339338
B::Owned: ~const Borrow<B>,

rust/alloc/boxed.rs

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ use crate::str::from_boxed_utf8_unchecked;
165165
#[cfg(not(no_global_oom_handling))]
166166
use crate::vec::Vec;
167167

168+
#[unstable(feature = "thin_box", issue = "92791")]
169+
pub use thin::ThinBox;
170+
171+
mod thin;
172+
168173
/// A pointer type for heap allocation.
169174
///
170175
/// See the [module-level documentation](../../std/boxed/index.html) for more.
@@ -351,10 +356,9 @@ impl<T, A: Allocator> Box<T, A> {
351356
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
352357
#[must_use]
353358
#[inline]
354-
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
355359
pub const fn new_in(x: T, alloc: A) -> Self
356360
where
357-
A: ~const Allocator + ~const Drop + ~const Destruct,
361+
A: ~const Allocator + ~const Destruct,
358362
{
359363
let mut boxed = Self::new_uninit_in(alloc);
360364
unsafe {
@@ -381,11 +385,10 @@ impl<T, A: Allocator> Box<T, A> {
381385
#[unstable(feature = "allocator_api", issue = "32838")]
382386
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
383387
#[inline]
384-
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
385388
pub const fn try_new_in(x: T, alloc: A) -> Result<Self, AllocError>
386389
where
387-
T: ~const Drop + ~const Destruct,
388-
A: ~const Allocator + ~const Drop + ~const Destruct,
390+
T: ~const Destruct,
391+
A: ~const Allocator + ~const Destruct,
389392
{
390393
let mut boxed = Self::try_new_uninit_in(alloc)?;
391394
unsafe {
@@ -419,10 +422,9 @@ impl<T, A: Allocator> Box<T, A> {
419422
#[cfg(not(no_global_oom_handling))]
420423
#[must_use]
421424
// #[unstable(feature = "new_uninit", issue = "63291")]
422-
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
423425
pub const fn new_uninit_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
424426
where
425-
A: ~const Allocator + ~const Drop + ~const Destruct,
427+
A: ~const Allocator + ~const Destruct,
426428
{
427429
let layout = Layout::new::<mem::MaybeUninit<T>>();
428430
// NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
@@ -458,10 +460,9 @@ impl<T, A: Allocator> Box<T, A> {
458460
#[unstable(feature = "allocator_api", issue = "32838")]
459461
// #[unstable(feature = "new_uninit", issue = "63291")]
460462
#[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
462463
pub const fn try_new_uninit_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
463464
where
464-
A: ~const Allocator + ~const Drop + ~const Destruct,
465+
A: ~const Allocator + ~const Destruct,
465466
{
466467
let layout = Layout::new::<mem::MaybeUninit<T>>();
467468
let ptr = alloc.allocate(layout)?.cast();
@@ -493,10 +494,9 @@ impl<T, A: Allocator> Box<T, A> {
493494
#[cfg(not(no_global_oom_handling))]
494495
// #[unstable(feature = "new_uninit", issue = "63291")]
495496
#[must_use]
496-
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
497497
pub const fn new_zeroed_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
498498
where
499-
A: ~const Allocator + ~const Drop + ~const Destruct,
499+
A: ~const Allocator + ~const Destruct,
500500
{
501501
let layout = Layout::new::<mem::MaybeUninit<T>>();
502502
// NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
@@ -532,10 +532,9 @@ impl<T, A: Allocator> Box<T, A> {
532532
#[unstable(feature = "allocator_api", issue = "32838")]
533533
// #[unstable(feature = "new_uninit", issue = "63291")]
534534
#[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
536535
pub const fn try_new_zeroed_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
537536
where
538-
A: ~const Allocator + ~const Drop + ~const Destruct,
537+
A: ~const Allocator + ~const Destruct,
539538
{
540539
let layout = Layout::new::<mem::MaybeUninit<T>>();
541540
let ptr = alloc.allocate_zeroed(layout)?.cast();
@@ -549,10 +548,9 @@ impl<T, A: Allocator> Box<T, A> {
549548
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
550549
#[must_use]
551550
#[inline(always)]
552-
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
553551
pub const fn pin_in(x: T, alloc: A) -> Pin<Self>
554552
where
555-
A: 'static + ~const Allocator + ~const Drop + ~const Destruct,
553+
A: 'static + ~const Allocator + ~const Destruct,
556554
{
557555
Self::into_pin(Self::new_in(x, alloc))
558556
}
@@ -581,10 +579,9 @@ impl<T, A: Allocator> Box<T, A> {
581579
#[unstable(feature = "box_into_inner", issue = "80437")]
582580
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
583581
#[inline]
584-
#[cfg_attr(not(bootstrap), allow(drop_bounds))] // FIXME remove `~const Drop` and this attr when bumping
585582
pub const fn into_inner(boxed: Self) -> T
586583
where
587-
Self: ~const Drop + ~const Destruct,
584+
Self: ~const Destruct,
588585
{
589586
*boxed
590587
}
@@ -1197,17 +1194,25 @@ impl<T: Default> Default for Box<T> {
11971194

11981195
#[cfg(not(no_global_oom_handling))]
11991196
#[stable(feature = "rust1", since = "1.0.0")]
1200-
impl<T> Default for Box<[T]> {
1197+
#[rustc_const_unstable(feature = "const_default_impls", issue = "87864")]
1198+
impl<T> const Default for Box<[T]> {
12011199
fn default() -> Self {
1202-
Box::<[T; 0]>::new([])
1200+
let ptr: Unique<[T]> = Unique::<[T; 0]>::dangling();
1201+
Box(ptr, Global)
12031202
}
12041203
}
12051204

12061205
#[cfg(not(no_global_oom_handling))]
12071206
#[stable(feature = "default_box_extra", since = "1.17.0")]
1208-
impl Default for Box<str> {
1207+
#[rustc_const_unstable(feature = "const_default_impls", issue = "87864")]
1208+
impl const Default for Box<str> {
12091209
fn default() -> Self {
1210-
unsafe { from_boxed_utf8_unchecked(Default::default()) }
1210+
// SAFETY: This is the same as `Unique::cast<U>` but with an unsized `U = str`.
1211+
let ptr: Unique<str> = unsafe {
1212+
let bytes: Unique<[u8]> = Unique::<[u8; 0]>::dangling();
1213+
Unique::new_unchecked(bytes.as_ptr() as *mut str)
1214+
};
1215+
Box(ptr, Global)
12111216
}
12121217
}
12131218

@@ -1366,6 +1371,12 @@ impl<T: ?Sized + Hasher, A: Allocator> Hasher for Box<T, A> {
13661371
fn write_isize(&mut self, i: isize) {
13671372
(**self).write_isize(i)
13681373
}
1374+
fn write_length_prefix(&mut self, len: usize) {
1375+
(**self).write_length_prefix(len)
1376+
}
1377+
fn write_str(&mut self, s: &str) {
1378+
(**self).write_str(s)
1379+
}
13691380
}
13701381

13711382
#[cfg(not(no_global_oom_handling))]

0 commit comments

Comments
 (0)