Skip to content

Commit a32f62f

Browse files
author
gitbot
committed
Merge from 9c27f27 with conflicts
2 parents 398ff24 + 83da666 commit a32f62f

File tree

228 files changed

+6731
-3386
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

228 files changed

+6731
-3386
lines changed

library/Cargo.lock

Lines changed: 23 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

library/alloc/src/borrow.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ use crate::fmt;
1717
use crate::string::String;
1818

1919
#[stable(feature = "rust1", since = "1.0.0")]
20-
impl<'a, B: ?Sized> Borrow<B> for Cow<'a, B>
20+
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
21+
impl<'a, B: ?Sized> const Borrow<B> for Cow<'a, B>
2122
where
2223
B: ToOwned,
24+
B::Owned: [const] Borrow<B>,
2325
{
2426
fn borrow(&self) -> &B {
2527
&**self
@@ -326,9 +328,10 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
326328
}
327329

328330
#[stable(feature = "rust1", since = "1.0.0")]
329-
impl<B: ?Sized + ToOwned> Deref for Cow<'_, B>
331+
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
332+
impl<B: ?Sized + ToOwned> const Deref for Cow<'_, B>
330333
where
331-
B::Owned: Borrow<B>,
334+
B::Owned: [const] Borrow<B>,
332335
{
333336
type Target = B;
334337

@@ -439,7 +442,11 @@ where
439442
}
440443

441444
#[stable(feature = "rust1", since = "1.0.0")]
442-
impl<T: ?Sized + ToOwned> AsRef<T> for Cow<'_, T> {
445+
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
446+
impl<T: ?Sized + ToOwned> const AsRef<T> for Cow<'_, T>
447+
where
448+
T::Owned: [const] Borrow<T>,
449+
{
443450
fn as_ref(&self) -> &T {
444451
self
445452
}

library/alloc/src/boxed.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,11 +2128,6 @@ impl<F: ?Sized + Future + Unpin, A: Allocator> Future for Box<F, A> {
21282128

21292129
#[stable(feature = "box_error", since = "1.8.0")]
21302130
impl<E: Error> Error for Box<E> {
2131-
#[allow(deprecated, deprecated_in_future)]
2132-
fn description(&self) -> &str {
2133-
Error::description(&**self)
2134-
}
2135-
21362131
#[allow(deprecated)]
21372132
fn cause(&self) -> Option<&dyn Error> {
21382133
Error::cause(&**self)

library/alloc/src/boxed/convert.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -608,12 +608,7 @@ impl<'a> From<String> for Box<dyn Error + Send + Sync + 'a> {
608608
fn from(err: String) -> Box<dyn Error + Send + Sync + 'a> {
609609
struct StringError(String);
610610

611-
impl Error for StringError {
612-
#[allow(deprecated)]
613-
fn description(&self) -> &str {
614-
&self.0
615-
}
616-
}
611+
impl Error for StringError {}
617612

618613
impl fmt::Display for StringError {
619614
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

library/alloc/src/collections/btree/map/entry.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,6 @@ impl<'a, K: Debug + Ord, V: Debug, A: Allocator + Clone> fmt::Display
136136
impl<'a, K: core::fmt::Debug + Ord, V: core::fmt::Debug> core::error::Error
137137
for crate::collections::btree_map::OccupiedError<'a, K, V>
138138
{
139-
#[allow(deprecated)]
140-
fn description(&self) -> &str {
141-
"key already exists"
142-
}
143139
}
144140

145141
impl<'a, K: Ord, V, A: Allocator + Clone> Entry<'a, K, V, A> {

library/alloc/src/collections/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,19 @@ pub use realalloc::collections::TryReserveErrorKind;
128128
reason = "Uncertain how much info should be exposed",
129129
issue = "48043"
130130
)]
131+
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
131132
#[cfg(not(test))]
132-
impl From<TryReserveErrorKind> for TryReserveError {
133+
impl const From<TryReserveErrorKind> for TryReserveError {
133134
#[inline]
134135
fn from(kind: TryReserveErrorKind) -> Self {
135136
Self { kind }
136137
}
137138
}
138139

139140
#[unstable(feature = "try_reserve_kind", reason = "new API", issue = "48043")]
141+
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
140142
#[cfg(not(test))]
141-
impl From<LayoutError> for TryReserveErrorKind {
143+
impl const From<LayoutError> for TryReserveErrorKind {
142144
/// Always evaluates to [`TryReserveErrorKind::CapacityOverflow`].
143145
#[inline]
144146
fn from(_: LayoutError) -> Self {

library/alloc/src/ffi/c_str.rs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,17 +1061,10 @@ impl IntoStringError {
10611061
}
10621062
}
10631063

1064-
impl IntoStringError {
1065-
fn description(&self) -> &str {
1066-
"C string contained non-utf8 bytes"
1067-
}
1068-
}
1069-
10701064
#[stable(feature = "cstring_into", since = "1.7.0")]
10711065
impl fmt::Display for IntoStringError {
1072-
#[allow(deprecated, deprecated_in_future)]
10731066
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1074-
self.description().fmt(f)
1067+
"C string contained non-utf8 bytes".fmt(f)
10751068
}
10761069
}
10771070

@@ -1291,23 +1284,13 @@ impl PartialEq<CString> for Cow<'_, CStr> {
12911284
}
12921285

12931286
#[stable(feature = "rust1", since = "1.0.0")]
1294-
impl core::error::Error for NulError {
1295-
#[allow(deprecated)]
1296-
fn description(&self) -> &str {
1297-
"nul byte found in data"
1298-
}
1299-
}
1287+
impl core::error::Error for NulError {}
13001288

13011289
#[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")]
13021290
impl core::error::Error for FromVecWithNulError {}
13031291

13041292
#[stable(feature = "cstring_into", since = "1.7.0")]
13051293
impl core::error::Error for IntoStringError {
1306-
#[allow(deprecated)]
1307-
fn description(&self) -> &str {
1308-
"C string contained non-utf8 bytes"
1309-
}
1310-
13111294
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
13121295
Some(&self.error)
13131296
}

library/alloc/src/fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@
354354
//! sign := '+' | '-'
355355
//! width := count
356356
//! precision := count | '*'
357-
//! type := '?' | 'x?' | 'X?' | identifier
357+
//! type := '?' | 'x?' | 'X?' | 'o' | 'x' | 'X' | 'p' | 'b' | 'e' | 'E'
358358
//! count := parameter | integer
359359
//! parameter := argument '$'
360360
//! ```

library/alloc/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@
108108
#![feature(char_max_len)]
109109
#![feature(clone_to_uninit)]
110110
#![feature(coerce_unsized)]
111+
#![feature(const_convert)]
111112
#![feature(const_default)]
112113
#![feature(const_eval_select)]
113114
#![feature(const_heap)]
114-
#![feature(const_trait_impl)]
115115
#![feature(core_intrinsics)]
116116
#![feature(deprecated_suggestion)]
117117
#![feature(deref_pure_trait)]
@@ -160,6 +160,7 @@
160160
#![feature(unicode_internals)]
161161
#![feature(unsize)]
162162
#![feature(unwrap_infallible)]
163+
#![feature(wtf8_internals)]
163164
// tidy-alphabetical-end
164165
//
165166
// Language features:
@@ -168,6 +169,7 @@
168169
#![feature(allow_internal_unstable)]
169170
#![feature(cfg_sanitize)]
170171
#![feature(const_precise_live_drops)]
172+
#![feature(const_trait_impl)]
171173
#![feature(coroutine_trait)]
172174
#![feature(decl_macro)]
173175
#![feature(dropck_eyepatch)]
@@ -233,6 +235,8 @@ pub mod sync;
233235
#[cfg(all(not(no_global_oom_handling), not(no_rc), not(no_sync)))]
234236
pub mod task;
235237
pub mod vec;
238+
#[cfg(all(not(no_rc), not(no_sync), not(no_global_oom_handling)))]
239+
pub mod wtf8;
236240

237241
#[doc(hidden)]
238242
#[unstable(feature = "liballoc_internals", issue = "none", reason = "implementation detail")]

library/alloc/src/raw_vec/mod.rs

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl RawVecInner<Global> {
155155
}
156156

157157
// Tiny Vecs are dumb. Skip to:
158-
// - 8 if the element size is 1, because any heap allocators is likely
158+
// - 8 if the element size is 1, because any heap allocator is likely
159159
// to round up a request of less than 8 bytes to at least 8 bytes.
160160
// - 4 if elements are moderate-sized (<= 1 KiB).
161161
// - 1 otherwise, to avoid wasting too much space for very short Vecs.
@@ -468,10 +468,6 @@ impl<A: Allocator> RawVecInner<A> {
468468
return Ok(Self::new_in(alloc, elem_layout.alignment()));
469469
}
470470

471-
if let Err(err) = alloc_guard(layout.size()) {
472-
return Err(err);
473-
}
474-
475471
let result = match init {
476472
AllocInit::Uninitialized => alloc.allocate(layout),
477473
#[cfg(not(no_global_oom_handling))]
@@ -662,7 +658,7 @@ impl<A: Allocator> RawVecInner<A> {
662658
let new_layout = layout_array(cap, elem_layout)?;
663659

664660
let ptr = finish_grow(new_layout, self.current_memory(elem_layout), &mut self.alloc)?;
665-
// SAFETY: finish_grow would have resulted in a capacity overflow if we tried to allocate more than `isize::MAX` items
661+
// SAFETY: layout_array would have resulted in a capacity overflow if we tried to allocate more than `isize::MAX` items
666662

667663
unsafe { self.set_ptr_and_cap(ptr, cap) };
668664
Ok(())
@@ -684,7 +680,7 @@ impl<A: Allocator> RawVecInner<A> {
684680
let new_layout = layout_array(cap, elem_layout)?;
685681

686682
let ptr = finish_grow(new_layout, self.current_memory(elem_layout), &mut self.alloc)?;
687-
// SAFETY: finish_grow would have resulted in a capacity overflow if we tried to allocate more than `isize::MAX` items
683+
// SAFETY: layout_array would have resulted in a capacity overflow if we tried to allocate more than `isize::MAX` items
688684
unsafe {
689685
self.set_ptr_and_cap(ptr, cap);
690686
}
@@ -771,8 +767,6 @@ fn finish_grow<A>(
771767
where
772768
A: Allocator,
773769
{
774-
alloc_guard(new_layout.size())?;
775-
776770
let memory = if let Some((ptr, old_layout)) = current_memory {
777771
debug_assert_eq!(old_layout.align(), new_layout.align());
778772
unsafe {
@@ -799,23 +793,6 @@ fn handle_error(e: TryReserveError) -> ! {
799793
}
800794
}
801795

802-
// We need to guarantee the following:
803-
// * We don't ever allocate `> isize::MAX` byte-size objects.
804-
// * We don't overflow `usize::MAX` and actually allocate too little.
805-
//
806-
// On 64-bit we just need to check for overflow since trying to allocate
807-
// `> isize::MAX` bytes will surely fail. On 32-bit and 16-bit we need to add
808-
// an extra guard for this in case we're running on a platform which can use
809-
// all 4GB in user-space, e.g., PAE or x32.
810-
#[inline]
811-
fn alloc_guard(alloc_size: usize) -> Result<(), TryReserveError> {
812-
if usize::BITS < 64 && alloc_size > isize::MAX as usize {
813-
Err(CapacityOverflow.into())
814-
} else {
815-
Ok(())
816-
}
817-
}
818-
819796
#[inline]
820797
fn layout_array(cap: usize, elem_layout: Layout) -> Result<Layout, TryReserveError> {
821798
elem_layout.repeat(cap).map(|(layout, _pad)| layout).map_err(|_| CapacityOverflow.into())

0 commit comments

Comments
 (0)