Skip to content

Commit 6609fe8

Browse files
committed
Merge from rustc
2 parents e7451ac + 2927248 commit 6609fe8

File tree

18 files changed

+97
-148
lines changed

18 files changed

+97
-148
lines changed

alloc/src/ffi/c_str.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -991,12 +991,6 @@ impl IntoStringError {
991991
pub fn utf8_error(&self) -> Utf8Error {
992992
self.error
993993
}
994-
995-
#[doc(hidden)]
996-
#[unstable(feature = "cstr_internals", issue = "none")]
997-
pub fn __source(&self) -> &Utf8Error {
998-
&self.error
999-
}
1000994
}
1001995

1002996
impl IntoStringError {
@@ -1141,6 +1135,6 @@ impl core::error::Error for IntoStringError {
11411135
}
11421136

11431137
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
1144-
Some(self.__source())
1138+
Some(&self.error)
11451139
}
11461140
}

alloc/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@
116116
#![feature(const_eval_select)]
117117
#![feature(const_pin)]
118118
#![feature(const_waker)]
119-
#![feature(cstr_from_bytes_until_nul)]
120119
#![feature(dispatch_from_dyn)]
121120
#![feature(error_generic_member_access)]
122121
#![feature(error_in_core)]

alloc/src/string.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,12 +928,12 @@ impl String {
928928

929929
/// Copies elements from `src` range to the end of the string.
930930
///
931-
/// ## Panics
931+
/// # Panics
932932
///
933933
/// Panics if the starting point or end point do not lie on a [`char`]
934934
/// boundary, or if they're out of bounds.
935935
///
936-
/// ## Examples
936+
/// # Examples
937937
///
938938
/// ```
939939
/// #![feature(string_extend_from_within)]

core/src/array/mod.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -131,28 +131,15 @@ pub struct TryFromSliceError(());
131131
impl fmt::Display for TryFromSliceError {
132132
#[inline]
133133
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
134-
fmt::Display::fmt(self.__description(), f)
134+
#[allow(deprecated)]
135+
self.description().fmt(f)
135136
}
136137
}
137138

138139
#[stable(feature = "try_from", since = "1.34.0")]
139140
impl Error for TryFromSliceError {
140141
#[allow(deprecated)]
141142
fn description(&self) -> &str {
142-
self.__description()
143-
}
144-
}
145-
146-
impl TryFromSliceError {
147-
#[unstable(
148-
feature = "array_error_internals",
149-
reason = "available through Error trait and this method should not \
150-
be exposed publicly",
151-
issue = "none"
152-
)]
153-
#[inline]
154-
#[doc(hidden)]
155-
pub fn __description(&self) -> &str {
156143
"could not convert slice to array"
157144
}
158145
}

core/src/char/convert.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use crate::char::TryFromCharError;
44
use crate::convert::TryFrom;
5+
use crate::error::Error;
56
use crate::fmt;
67
use crate::mem::transmute;
78
use crate::str::FromStr;
@@ -150,31 +151,28 @@ pub struct ParseCharError {
150151
kind: CharErrorKind,
151152
}
152153

153-
impl ParseCharError {
154-
#[unstable(
155-
feature = "char_error_internals",
156-
reason = "this method should not be available publicly",
157-
issue = "none"
158-
)]
159-
#[doc(hidden)]
160-
pub fn __description(&self) -> &str {
154+
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
155+
enum CharErrorKind {
156+
EmptyString,
157+
TooManyChars,
158+
}
159+
160+
#[stable(feature = "char_from_str", since = "1.20.0")]
161+
impl Error for ParseCharError {
162+
#[allow(deprecated)]
163+
fn description(&self) -> &str {
161164
match self.kind {
162165
CharErrorKind::EmptyString => "cannot parse char from empty string",
163166
CharErrorKind::TooManyChars => "too many characters in string",
164167
}
165168
}
166169
}
167170

168-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
169-
enum CharErrorKind {
170-
EmptyString,
171-
TooManyChars,
172-
}
173-
174171
#[stable(feature = "char_from_str", since = "1.20.0")]
175172
impl fmt::Display for ParseCharError {
176173
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
177-
self.__description().fmt(f)
174+
#[allow(deprecated)]
175+
self.description().fmt(f)
178176
}
179177
}
180178

core/src/error.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -486,26 +486,10 @@ impl Error for crate::char::CharTryFromError {
486486
}
487487
}
488488

489-
#[stable(feature = "char_from_str", since = "1.20.0")]
490-
impl Error for crate::char::ParseCharError {
491-
#[allow(deprecated)]
492-
fn description(&self) -> &str {
493-
self.__description()
494-
}
495-
}
496-
497489
#[stable(feature = "duration_checked_float", since = "1.66.0")]
498490
impl Error for crate::time::TryFromFloatSecsError {}
499491

500-
#[stable(feature = "frombyteswithnulerror_impls", since = "1.17.0")]
501-
impl Error for crate::ffi::FromBytesWithNulError {
502-
#[allow(deprecated)]
503-
fn description(&self) -> &str {
504-
self.__description()
505-
}
506-
}
507-
508-
#[unstable(feature = "cstr_from_bytes_until_nul", issue = "95027")]
492+
#[stable(feature = "cstr_from_bytes_until_nul", since = "CURRENT_RUSTC_VERSION")]
509493
impl Error for crate::ffi::FromBytesUntilNulError {}
510494

511495
#[unstable(feature = "get_many_mut", issue = "104642")]

core/src/ffi/c_str.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::cmp::Ordering;
2+
use crate::error::Error;
23
use crate::ffi::c_char;
34
use crate::fmt;
45
use crate::intrinsics;
@@ -129,10 +130,12 @@ impl FromBytesWithNulError {
129130
const fn not_nul_terminated() -> FromBytesWithNulError {
130131
FromBytesWithNulError { kind: FromBytesWithNulErrorKind::NotNulTerminated }
131132
}
133+
}
132134

133-
#[doc(hidden)]
134-
#[unstable(feature = "cstr_internals", issue = "none")]
135-
pub fn __description(&self) -> &str {
135+
#[stable(feature = "frombyteswithnulerror_impls", since = "1.17.0")]
136+
impl Error for FromBytesWithNulError {
137+
#[allow(deprecated)]
138+
fn description(&self) -> &str {
136139
match self.kind {
137140
FromBytesWithNulErrorKind::InteriorNul(..) => {
138141
"data provided contains an interior nul byte"
@@ -150,10 +153,10 @@ impl FromBytesWithNulError {
150153
/// This error is created by the [`CStr::from_bytes_until_nul`] method.
151154
///
152155
#[derive(Clone, PartialEq, Eq, Debug)]
153-
#[unstable(feature = "cstr_from_bytes_until_nul", issue = "95027")]
156+
#[stable(feature = "cstr_from_bytes_until_nul", since = "CURRENT_RUSTC_VERSION")]
154157
pub struct FromBytesUntilNulError(());
155158

156-
#[unstable(feature = "cstr_from_bytes_until_nul", issue = "95027")]
159+
#[stable(feature = "cstr_from_bytes_until_nul", since = "CURRENT_RUSTC_VERSION")]
157160
impl fmt::Display for FromBytesUntilNulError {
158161
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
159162
write!(f, "data provided does not contain a nul")
@@ -180,7 +183,7 @@ impl Default for &CStr {
180183
impl fmt::Display for FromBytesWithNulError {
181184
#[allow(deprecated, deprecated_in_future)]
182185
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
183-
f.write_str(self.__description())?;
186+
f.write_str(self.description())?;
184187
if let FromBytesWithNulErrorKind::InteriorNul(pos) = self.kind {
185188
write!(f, " at byte pos {pos}")?;
186189
}
@@ -306,8 +309,6 @@ impl CStr {
306309
///
307310
/// # Examples
308311
/// ```
309-
/// #![feature(cstr_from_bytes_until_nul)]
310-
///
311312
/// use std::ffi::CStr;
312313
///
313314
/// let mut buffer = [0u8; 16];
@@ -322,8 +323,9 @@ impl CStr {
322323
/// assert_eq!(c_str.to_str().unwrap(), "AAAAAAAA");
323324
/// ```
324325
///
325-
#[unstable(feature = "cstr_from_bytes_until_nul", issue = "95027")]
326-
#[rustc_const_unstable(feature = "cstr_from_bytes_until_nul", issue = "95027")]
326+
#[rustc_allow_const_fn_unstable(const_slice_index)]
327+
#[stable(feature = "cstr_from_bytes_until_nul", since = "CURRENT_RUSTC_VERSION")]
328+
#[rustc_const_stable(feature = "cstr_from_bytes_until_nul", since = "CURRENT_RUSTC_VERSION")]
327329
pub const fn from_bytes_until_nul(bytes: &[u8]) -> Result<&CStr, FromBytesUntilNulError> {
328330
let nul_pos = memchr::memchr(0, bytes);
329331
match nul_pos {

core/src/marker.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -872,13 +872,14 @@ pub trait Destruct {}
872872
pub trait Tuple {}
873873

874874
/// A marker for things
875-
#[unstable(feature = "pointer_sized_trait", issue = "none")]
876-
#[lang = "pointer_sized"]
875+
#[unstable(feature = "pointer_like_trait", issue = "none")]
876+
#[cfg_attr(bootstrap, lang = "pointer_sized")]
877+
#[cfg_attr(not(bootstrap), lang = "pointer_like")]
877878
#[rustc_on_unimplemented(
878-
message = "`{Self}` needs to be a pointer-sized type",
879-
label = "`{Self}` needs to be a pointer-sized type"
879+
message = "`{Self}` needs to have the same alignment and size as a pointer",
880+
label = "`{Self}` needs to be a pointer-like type"
880881
)]
881-
pub trait PointerSized {}
882+
pub trait PointerLike {}
882883

883884
/// Implementations of `Copy` for primitive types.
884885
///

core/src/num/dec2flt/mod.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
issue = "none"
7676
)]
7777

78+
use crate::error::Error;
7879
use crate::fmt;
7980
use crate::str::FromStr;
8081

@@ -182,15 +183,10 @@ enum FloatErrorKind {
182183
Invalid,
183184
}
184185

185-
impl ParseFloatError {
186-
#[unstable(
187-
feature = "int_error_internals",
188-
reason = "available through Error trait and this method should \
189-
not be exposed publicly",
190-
issue = "none"
191-
)]
192-
#[doc(hidden)]
193-
pub fn __description(&self) -> &str {
186+
#[stable(feature = "rust1", since = "1.0.0")]
187+
impl Error for ParseFloatError {
188+
#[allow(deprecated)]
189+
fn description(&self) -> &str {
194190
match self.kind {
195191
FloatErrorKind::Empty => "cannot parse float from empty string",
196192
FloatErrorKind::Invalid => "invalid float literal",
@@ -201,7 +197,8 @@ impl ParseFloatError {
201197
#[stable(feature = "rust1", since = "1.0.0")]
202198
impl fmt::Display for ParseFloatError {
203199
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
204-
self.__description().fmt(f)
200+
#[allow(deprecated)]
201+
self.description().fmt(f)
205202
}
206203
}
207204

core/src/num/error.rs

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,19 @@ use crate::fmt;
99
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
1010
pub struct TryFromIntError(pub(crate) ());
1111

12-
impl TryFromIntError {
13-
#[unstable(
14-
feature = "int_error_internals",
15-
reason = "available through Error trait and this method should \
16-
not be exposed publicly",
17-
issue = "none"
18-
)]
19-
#[doc(hidden)]
20-
pub fn __description(&self) -> &str {
21-
"out of range integral type conversion attempted"
12+
#[stable(feature = "try_from", since = "1.34.0")]
13+
impl fmt::Display for TryFromIntError {
14+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
15+
#[allow(deprecated)]
16+
self.description().fmt(fmt)
2217
}
2318
}
2419

2520
#[stable(feature = "try_from", since = "1.34.0")]
26-
impl fmt::Display for TryFromIntError {
27-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
28-
self.__description().fmt(fmt)
21+
impl Error for TryFromIntError {
22+
#[allow(deprecated)]
23+
fn description(&self) -> &str {
24+
"out of range integral type conversion attempted"
2925
}
3026
}
3127

@@ -121,43 +117,26 @@ impl ParseIntError {
121117
pub fn kind(&self) -> &IntErrorKind {
122118
&self.kind
123119
}
124-
#[unstable(
125-
feature = "int_error_internals",
126-
reason = "available through Error trait and this method should \
127-
not be exposed publicly",
128-
issue = "none"
129-
)]
130-
#[doc(hidden)]
131-
pub fn __description(&self) -> &str {
132-
match self.kind {
133-
IntErrorKind::Empty => "cannot parse integer from empty string",
134-
IntErrorKind::InvalidDigit => "invalid digit found in string",
135-
IntErrorKind::PosOverflow => "number too large to fit in target type",
136-
IntErrorKind::NegOverflow => "number too small to fit in target type",
137-
IntErrorKind::Zero => "number would be zero for non-zero type",
138-
}
139-
}
140120
}
141121

142122
#[stable(feature = "rust1", since = "1.0.0")]
143123
impl fmt::Display for ParseIntError {
144124
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
145-
self.__description().fmt(f)
125+
#[allow(deprecated)]
126+
self.description().fmt(f)
146127
}
147128
}
148129

149130
#[stable(feature = "rust1", since = "1.0.0")]
150131
impl Error for ParseIntError {
151132
#[allow(deprecated)]
152133
fn description(&self) -> &str {
153-
self.__description()
154-
}
155-
}
156-
157-
#[stable(feature = "try_from", since = "1.34.0")]
158-
impl Error for TryFromIntError {
159-
#[allow(deprecated)]
160-
fn description(&self) -> &str {
161-
self.__description()
134+
match self.kind {
135+
IntErrorKind::Empty => "cannot parse integer from empty string",
136+
IntErrorKind::InvalidDigit => "invalid digit found in string",
137+
IntErrorKind::PosOverflow => "number too large to fit in target type",
138+
IntErrorKind::NegOverflow => "number too small to fit in target type",
139+
IntErrorKind::Zero => "number would be zero for non-zero type",
140+
}
162141
}
163142
}

0 commit comments

Comments
 (0)