Skip to content

Commit 18b7491

Browse files
authored
Merge pull request #1027 from ojeda/rust-rust-1.71
Rust 1.71.0
2 parents c8d1ae2 + 4928570 commit 18b7491

File tree

20 files changed

+139
-133
lines changed

20 files changed

+139
-133
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.70.0
10+
container: ghcr.io/rust-for-linux/ci:Rust-1.71.0
1111
timeout-minutes: 25
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.70.0 rustc --version
34+
Rust (optional) 1.71.0 rustc --version
3535
bindgen (optional) 0.56.0 bindgen --version
3636
GNU make 3.82 make --version
3737
bash 4.2 bash --version

rust/Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,13 @@ rust-analyzer:
396396
$(RUST_LIB_SRC) > $(objtree)/rust-project.json
397397

398398
redirect-intrinsics = \
399-
__eqsf2 __gesf2 __lesf2 __nesf2 __unordsf2 \
400-
__unorddf2 \
399+
__addsf3 __eqsf2 __gesf2 __lesf2 __ltsf2 __mulsf3 __nesf2 __subsf3 __unordsf2 \
400+
__adddf3 __ledf2 __ltdf2 __muldf3 __unorddf2 \
401401
__muloti4 __multi3 \
402402
__udivmodti4 __udivti3 __umodti3 \
403-
__aeabi_fcmpeq __aeabi_fcmpun __aeabi_dcmpun __aeabi_uldivmod
403+
__aeabi_fadd __aeabi_fmul __aeabi_fcmpeq __aeabi_fcmple __aeabi_fcmplt __aeabi_fcmpun \
404+
__aeabi_dadd __aeabi_dmul __aeabi_dcmple __aeabi_dcmplt __aeabi_dcmpun \
405+
__aeabi_uldivmod
404406

405407
ifneq ($(or $(CONFIG_ARM64),$(and $(CONFIG_RISCV),$(CONFIG_64BIT))),)
406408
# These intrinsics are defined for ARM64 and RISCV64

rust/alloc/alloc.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ extern "Rust" {
3939
#[rustc_allocator_zeroed]
4040
#[rustc_nounwind]
4141
fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8;
42+
43+
#[cfg(not(bootstrap))]
44+
static __rust_no_alloc_shim_is_unstable: u8;
4245
}
4346

4447
/// The global memory allocator.
@@ -92,7 +95,14 @@ pub use std::alloc::Global;
9295
#[must_use = "losing the pointer will leak memory"]
9396
#[inline]
9497
pub unsafe fn alloc(layout: Layout) -> *mut u8 {
95-
unsafe { __rust_alloc(layout.size(), layout.align()) }
98+
unsafe {
99+
// Make sure we don't accidentally allow omitting the allocator shim in
100+
// stable code until it is actually stabilized.
101+
#[cfg(not(bootstrap))]
102+
core::ptr::read_volatile(&__rust_no_alloc_shim_is_unstable);
103+
104+
__rust_alloc(layout.size(), layout.align())
105+
}
96106
}
97107

98108
/// Deallocate memory with the global allocator.

rust/alloc/borrow.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ where
117117
/// ```
118118
/// use std::borrow::Cow;
119119
///
120-
/// fn abs_all(input: &mut Cow<[i32]>) {
120+
/// fn abs_all(input: &mut Cow<'_, [i32]>) {
121121
/// for i in 0..input.len() {
122122
/// let v = input[i];
123123
/// if v < 0 {
@@ -147,7 +147,7 @@ where
147147
/// ```
148148
/// use std::borrow::Cow;
149149
///
150-
/// struct Items<'a, X: 'a> where [X]: ToOwned<Owned = Vec<X>> {
150+
/// struct Items<'a, X> where [X]: ToOwned<Owned = Vec<X>> {
151151
/// values: Cow<'a, [X]>,
152152
/// }
153153
///
@@ -269,7 +269,7 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
269269
///
270270
/// assert_eq!(
271271
/// cow,
272-
/// Cow::Owned(String::from("FOO")) as Cow<str>
272+
/// Cow::Owned(String::from("FOO")) as Cow<'_, str>
273273
/// );
274274
/// ```
275275
#[stable(feature = "rust1", since = "1.0.0")]
@@ -313,7 +313,7 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
313313
/// use std::borrow::Cow;
314314
///
315315
/// let s = "Hello world!";
316-
/// let cow: Cow<str> = Cow::Owned(String::from(s));
316+
/// let cow: Cow<'_, str> = Cow::Owned(String::from(s));
317317
///
318318
/// assert_eq!(
319319
/// cow.into_owned(),

rust/alloc/boxed.rs

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,7 @@ impl<T, A: Allocator> Box<T, A> {
578578
///
579579
/// This conversion does not allocate on the heap and happens in place.
580580
#[unstable(feature = "box_into_boxed_slice", issue = "71582")]
581-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
582-
pub const fn into_boxed_slice(boxed: Self) -> Box<[T], A> {
581+
pub fn into_boxed_slice(boxed: Self) -> Box<[T], A> {
583582
let (raw, alloc) = Box::into_raw_with_allocator(boxed);
584583
unsafe { Box::from_raw_in(raw as *mut [T; 1], alloc) }
585584
}
@@ -811,9 +810,8 @@ impl<T, A: Allocator> Box<mem::MaybeUninit<T>, A> {
811810
/// assert_eq!(*five, 5)
812811
/// ```
813812
#[unstable(feature = "new_uninit", issue = "63291")]
814-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
815813
#[inline]
816-
pub const unsafe fn assume_init(self) -> Box<T, A> {
814+
pub unsafe fn assume_init(self) -> Box<T, A> {
817815
let (raw, alloc) = Box::into_raw_with_allocator(self);
818816
unsafe { Box::from_raw_in(raw as *mut T, alloc) }
819817
}
@@ -846,9 +844,8 @@ impl<T, A: Allocator> Box<mem::MaybeUninit<T>, A> {
846844
/// }
847845
/// ```
848846
#[unstable(feature = "new_uninit", issue = "63291")]
849-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
850847
#[inline]
851-
pub const fn write(mut boxed: Self, value: T) -> Box<T, A> {
848+
pub fn write(mut boxed: Self, value: T) -> Box<T, A> {
852849
unsafe {
853850
(*boxed).write(value);
854851
boxed.assume_init()
@@ -1092,9 +1089,8 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
10921089
///
10931090
/// [memory layout]: self#memory-layout
10941091
#[unstable(feature = "allocator_api", issue = "32838")]
1095-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
10961092
#[inline]
1097-
pub const fn into_raw_with_allocator(b: Self) -> (*mut T, A) {
1093+
pub fn into_raw_with_allocator(b: Self) -> (*mut T, A) {
10981094
let (leaked, alloc) = Box::into_unique(b);
10991095
(leaked.as_ptr(), alloc)
11001096
}
@@ -1104,10 +1100,9 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
11041100
issue = "none",
11051101
reason = "use `Box::leak(b).into()` or `Unique::from(Box::leak(b))` instead"
11061102
)]
1107-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
11081103
#[inline]
11091104
#[doc(hidden)]
1110-
pub const fn into_unique(b: Self) -> (Unique<T>, A) {
1105+
pub fn into_unique(b: Self) -> (Unique<T>, A) {
11111106
// Box is recognized as a "unique pointer" by Stacked Borrows, but internally it is a
11121107
// raw pointer for the type system. Turning it directly into a raw pointer would not be
11131108
// recognized as "releasing" the unique pointer to permit aliased raw accesses,
@@ -1165,9 +1160,8 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
11651160
/// assert_eq!(*static_ref, [4, 2, 3]);
11661161
/// ```
11671162
#[stable(feature = "box_leak", since = "1.26.0")]
1168-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
11691163
#[inline]
1170-
pub const fn leak<'a>(b: Self) -> &'a mut T
1164+
pub fn leak<'a>(b: Self) -> &'a mut T
11711165
where
11721166
A: 'a,
11731167
{
@@ -1236,8 +1230,7 @@ impl<T: Default> Default for Box<T> {
12361230

12371231
#[cfg(not(no_global_oom_handling))]
12381232
#[stable(feature = "rust1", since = "1.0.0")]
1239-
#[rustc_const_unstable(feature = "const_default_impls", issue = "87864")]
1240-
impl<T> const Default for Box<[T]> {
1233+
impl<T> Default for Box<[T]> {
12411234
#[inline]
12421235
fn default() -> Self {
12431236
let ptr: Unique<[T]> = Unique::<[T; 0]>::dangling();
@@ -1247,8 +1240,7 @@ impl<T> const Default for Box<[T]> {
12471240

12481241
#[cfg(not(no_global_oom_handling))]
12491242
#[stable(feature = "default_box_extra", since = "1.17.0")]
1250-
#[rustc_const_unstable(feature = "const_default_impls", issue = "87864")]
1251-
impl const Default for Box<str> {
1243+
impl Default for Box<str> {
12521244
#[inline]
12531245
fn default() -> Self {
12541246
// SAFETY: This is the same as `Unique::cast<U>` but with an unsized `U = str`.
@@ -1445,8 +1437,7 @@ impl<T> From<T> for Box<T> {
14451437
}
14461438

14471439
#[stable(feature = "pin", since = "1.33.0")]
1448-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
1449-
impl<T: ?Sized, A: Allocator> const From<Box<T, A>> for Pin<Box<T, A>>
1440+
impl<T: ?Sized, A: Allocator> From<Box<T, A>> for Pin<Box<T, A>>
14501441
where
14511442
A: 'static,
14521443
{
@@ -1466,9 +1457,36 @@ where
14661457
}
14671458
}
14681459

1460+
/// Specialization trait used for `From<&[T]>`.
1461+
#[cfg(not(no_global_oom_handling))]
1462+
trait BoxFromSlice<T> {
1463+
fn from_slice(slice: &[T]) -> Self;
1464+
}
1465+
1466+
#[cfg(not(no_global_oom_handling))]
1467+
impl<T: Clone> BoxFromSlice<T> for Box<[T]> {
1468+
#[inline]
1469+
default fn from_slice(slice: &[T]) -> Self {
1470+
slice.to_vec().into_boxed_slice()
1471+
}
1472+
}
1473+
1474+
#[cfg(not(no_global_oom_handling))]
1475+
impl<T: Copy> BoxFromSlice<T> for Box<[T]> {
1476+
#[inline]
1477+
fn from_slice(slice: &[T]) -> Self {
1478+
let len = slice.len();
1479+
let buf = RawVec::with_capacity(len);
1480+
unsafe {
1481+
ptr::copy_nonoverlapping(slice.as_ptr(), buf.ptr(), len);
1482+
buf.into_box(slice.len()).assume_init()
1483+
}
1484+
}
1485+
}
1486+
14691487
#[cfg(not(no_global_oom_handling))]
14701488
#[stable(feature = "box_from_slice", since = "1.17.0")]
1471-
impl<T: Copy> From<&[T]> for Box<[T]> {
1489+
impl<T: Clone> From<&[T]> for Box<[T]> {
14721490
/// Converts a `&[T]` into a `Box<[T]>`
14731491
///
14741492
/// This conversion allocates on the heap
@@ -1482,19 +1500,15 @@ impl<T: Copy> From<&[T]> for Box<[T]> {
14821500
///
14831501
/// println!("{boxed_slice:?}");
14841502
/// ```
1503+
#[inline]
14851504
fn from(slice: &[T]) -> Box<[T]> {
1486-
let len = slice.len();
1487-
let buf = RawVec::with_capacity(len);
1488-
unsafe {
1489-
ptr::copy_nonoverlapping(slice.as_ptr(), buf.ptr(), len);
1490-
buf.into_box(slice.len()).assume_init()
1491-
}
1505+
<Self as BoxFromSlice<T>>::from_slice(slice)
14921506
}
14931507
}
14941508

14951509
#[cfg(not(no_global_oom_handling))]
14961510
#[stable(feature = "box_from_cow", since = "1.45.0")]
1497-
impl<T: Copy> From<Cow<'_, [T]>> for Box<[T]> {
1511+
impl<T: Clone> From<Cow<'_, [T]>> for Box<[T]> {
14981512
/// Converts a `Cow<'_, [T]>` into a `Box<[T]>`
14991513
///
15001514
/// When `cow` is the `Cow::Borrowed` variant, this
@@ -1882,8 +1896,7 @@ impl<T: ?Sized, A: Allocator> fmt::Pointer for Box<T, A> {
18821896
}
18831897

18841898
#[stable(feature = "rust1", since = "1.0.0")]
1885-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
1886-
impl<T: ?Sized, A: Allocator> const Deref for Box<T, A> {
1899+
impl<T: ?Sized, A: Allocator> Deref for Box<T, A> {
18871900
type Target = T;
18881901

18891902
fn deref(&self) -> &T {
@@ -1892,8 +1905,7 @@ impl<T: ?Sized, A: Allocator> const Deref for Box<T, A> {
18921905
}
18931906

18941907
#[stable(feature = "rust1", since = "1.0.0")]
1895-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
1896-
impl<T: ?Sized, A: Allocator> const DerefMut for Box<T, A> {
1908+
impl<T: ?Sized, A: Allocator> DerefMut for Box<T, A> {
18971909
fn deref_mut(&mut self) -> &mut T {
18981910
&mut **self
18991911
}

rust/alloc/boxed/thin.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use core::fmt::{self, Debug, Display, Formatter};
99
use core::marker::PhantomData;
1010
#[cfg(not(no_global_oom_handling))]
1111
use core::marker::Unsize;
12-
use core::mem;
12+
use core::mem::{self, SizedTypeProperties};
1313
use core::ops::{Deref, DerefMut};
1414
use core::ptr::Pointee;
1515
use core::ptr::{self, NonNull};
@@ -204,9 +204,7 @@ impl<H> WithHeader<H> {
204204
let ptr = if layout.size() == 0 {
205205
// Some paranoia checking, mostly so that the ThinBox tests are
206206
// more able to catch issues.
207-
debug_assert!(
208-
value_offset == 0 && mem::size_of::<T>() == 0 && mem::size_of::<H>() == 0
209-
);
207+
debug_assert!(value_offset == 0 && T::IS_ZST && H::IS_ZST);
210208
layout.dangling()
211209
} else {
212210
let ptr = alloc::alloc(layout);
@@ -251,9 +249,7 @@ impl<H> WithHeader<H> {
251249
alloc::dealloc(self.ptr.as_ptr().sub(value_offset), layout);
252250
} else {
253251
debug_assert!(
254-
value_offset == 0
255-
&& mem::size_of::<H>() == 0
256-
&& self.value_layout.size() == 0
252+
value_offset == 0 && H::IS_ZST && self.value_layout.size() == 0
257253
);
258254
}
259255
}

rust/alloc/fmt.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@
365365
//! # use std::fmt;
366366
//! # struct Foo; // our custom type
367367
//! # impl fmt::Display for Foo {
368-
//! fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
368+
//! fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
369369
//! # write!(f, "testing, testing")
370370
//! # } }
371371
//! ```
@@ -401,7 +401,7 @@
401401
//! }
402402
//!
403403
//! impl fmt::Display for Vector2D {
404-
//! fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
404+
//! fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
405405
//! // The `f` value implements the `Write` trait, which is what the
406406
//! // write! macro is expecting. Note that this formatting ignores the
407407
//! // various flags provided to format strings.
@@ -412,7 +412,7 @@
412412
//! // Different traits allow different forms of output of a type. The meaning
413413
//! // of this format is to print the magnitude of a vector.
414414
//! impl fmt::Binary for Vector2D {
415-
//! fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
415+
//! fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
416416
//! let magnitude = (self.x * self.x + self.y * self.y) as f64;
417417
//! let magnitude = magnitude.sqrt();
418418
//!
@@ -519,7 +519,7 @@
519519
//! let mut some_writer = io::stdout();
520520
//! write!(&mut some_writer, "{}", format_args!("print with a {}", "macro"));
521521
//!
522-
//! fn my_fmt_fn(args: fmt::Arguments) {
522+
//! fn my_fmt_fn(args: fmt::Arguments<'_>) {
523523
//! write!(&mut io::stdout(), "{args}");
524524
//! }
525525
//! my_fmt_fn(format_args!(", or a {} too", "function"));
@@ -553,8 +553,6 @@
553553
554554
#![stable(feature = "rust1", since = "1.0.0")]
555555

556-
#[unstable(feature = "fmt_internals", issue = "none")]
557-
pub use core::fmt::rt;
558556
#[stable(feature = "fmt_flags_align", since = "1.28.0")]
559557
pub use core::fmt::Alignment;
560558
#[stable(feature = "rust1", since = "1.0.0")]

rust/alloc/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,18 @@
103103
#![feature(array_into_iter_constructors)]
104104
#![feature(array_methods)]
105105
#![feature(array_windows)]
106+
#![feature(ascii_char)]
106107
#![feature(assert_matches)]
107108
#![feature(async_iterator)]
108109
#![feature(coerce_unsized)]
109110
#![feature(const_align_of_val)]
110111
#![feature(const_box)]
111-
#![feature(const_convert)]
112-
#![feature(const_cow_is_borrowed)]
112+
#![cfg_attr(not(no_borrow), feature(const_cow_is_borrowed))]
113113
#![feature(const_eval_select)]
114114
#![feature(const_maybe_uninit_as_mut_ptr)]
115115
#![feature(const_maybe_uninit_write)]
116116
#![feature(const_maybe_uninit_zeroed)]
117117
#![feature(const_pin)]
118-
#![feature(const_ptr_read)]
119118
#![feature(const_refs_to_cell)]
120119
#![feature(const_size_of_val)]
121120
#![feature(const_waker)]
@@ -176,7 +175,6 @@
176175
#![feature(associated_type_bounds)]
177176
#![feature(c_unwind)]
178177
#![feature(cfg_sanitize)]
179-
#![feature(const_deref)]
180178
#![feature(const_mut_refs)]
181179
#![feature(const_precise_live_drops)]
182180
#![feature(const_ptr_write)]

rust/alloc/str.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,12 @@ impl str {
406406
// See https://www.unicode.org/versions/Unicode7.0.0/ch03.pdf#G33992
407407
// for the definition of `Final_Sigma`.
408408
debug_assert!('Σ'.len_utf8() == 2);
409-
let is_word_final = case_ignoreable_then_cased(from[..i].chars().rev())
410-
&& !case_ignoreable_then_cased(from[i + 2..].chars());
409+
let is_word_final = case_ignorable_then_cased(from[..i].chars().rev())
410+
&& !case_ignorable_then_cased(from[i + 2..].chars());
411411
to.push_str(if is_word_final { "ς" } else { "σ" });
412412
}
413413

414-
fn case_ignoreable_then_cased<I: Iterator<Item = char>>(iter: I) -> bool {
414+
fn case_ignorable_then_cased<I: Iterator<Item = char>>(iter: I) -> bool {
415415
use core::unicode::{Case_Ignorable, Cased};
416416
match iter.skip_while(|&c| Case_Ignorable(c)).next() {
417417
Some(c) => Cased(c),

0 commit comments

Comments
 (0)