Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b42d648

Browse files
committedAug 2, 2022
checkpoint
1 parent 0afce62 commit b42d648

File tree

20 files changed

+902
-677
lines changed

20 files changed

+902
-677
lines changed
 

‎library/alloc/src/boxed.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2365,3 +2365,21 @@ impl<'a> From<Cow<'a, str>> for Box<dyn Error> {
23652365
From::from(String::from(err))
23662366
}
23672367
}
2368+
2369+
#[cfg(not(bootstrap))]
2370+
#[stable(feature = "box_error", since = "1.8.0")]
2371+
impl<T: core::error::Error> core::error::Error for Box<T> {
2372+
#[allow(deprecated, deprecated_in_future)]
2373+
fn description(&self) -> &str {
2374+
core::error::Error::description(&**self)
2375+
}
2376+
2377+
#[allow(deprecated)]
2378+
fn cause(&self) -> Option<&dyn core::error::Error> {
2379+
core::error::Error::cause(&**self)
2380+
}
2381+
2382+
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
2383+
core::error::Error::source(&**self)
2384+
}
2385+
}

‎library/alloc/src/boxed/thin.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// https://github.com/matthieu-m/rfc2580/blob/b58d1d3cba0d4b5e859d3617ea2d0943aaa31329/examples/thin.rs
33
// by matthieu-m
44
use crate::alloc::{self, Layout, LayoutError};
5+
#[cfg(not(bootstrap))]
6+
use core::error::Error;
57
use core::fmt::{self, Debug, Display, Formatter};
68
use core::marker::PhantomData;
79
#[cfg(not(no_global_oom_handling))]
@@ -271,3 +273,11 @@ impl<H> WithHeader<H> {
271273
Layout::new::<H>().extend(value_layout)
272274
}
273275
}
276+
277+
#[cfg(not(bootstrap))]
278+
#[unstable(feature = "thin_box", issue = "92791")]
279+
impl<T: ?Sized + Error> Error for ThinBox<T> {
280+
fn source(&self) -> Option<&(dyn Error + 'static)> {
281+
self.deref().source()
282+
}
283+
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,17 @@ impl<'a, K: Debug + Ord, V: Debug, A: Allocator + Clone> fmt::Display
133133
}
134134
}
135135

136+
#[cfg(not(bootstrap))]
137+
#[unstable(feature = "map_try_insert", issue = "82766")]
138+
impl<'a, K: core::fmt::Debug + Ord, V: core::fmt::Debug> core::error::Error
139+
for crate::collections::btree_map::OccupiedError<'a, K, V>
140+
{
141+
#[allow(deprecated)]
142+
fn description(&self) -> &str {
143+
"key already exists"
144+
}
145+
}
146+
136147
impl<'a, K: Ord, V, A: Allocator + Clone> Entry<'a, K, V, A> {
137148
/// Ensures a value is in the entry by inserting the default if empty, and returns
138149
/// a mutable reference to the value in the entry.

‎library/alloc/src/lib.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
#![feature(const_pin)]
112112
#![feature(cstr_from_bytes_until_nul)]
113113
#![feature(dispatch_from_dyn)]
114+
#![cfg_attr(not(bootstrap), feature(error_generic_member_access))]
114115
#![cfg_attr(not(bootstrap), feature(error_in_core))]
115116
#![feature(exact_size_is_empty)]
116117
#![feature(extend_one)]
@@ -128,6 +129,7 @@
128129
#![feature(nonnull_slice_from_raw_parts)]
129130
#![feature(pattern)]
130131
#![feature(pointer_byte_offsets)]
132+
#![cfg_attr(not(bootstrap), feature(provide_any))]
131133
#![feature(ptr_internals)]
132134
#![feature(ptr_metadata)]
133135
#![feature(ptr_sub_ptr)]
@@ -240,3 +242,55 @@ pub mod vec;
240242
pub mod __export {
241243
pub use core::format_args;
242244
}
245+
246+
#[cfg(not(bootstrap))]
247+
#[stable(feature = "arc_error", since = "1.52.0")]
248+
impl<T: core::error::Error + ?Sized> core::error::Error for crate::sync::Arc<T> {
249+
#[allow(deprecated, deprecated_in_future)]
250+
fn description(&self) -> &str {
251+
core::error::Error::description(&**self)
252+
}
253+
254+
#[allow(deprecated)]
255+
fn cause(&self) -> Option<&dyn core::error::Error> {
256+
core::error::Error::cause(&**self)
257+
}
258+
259+
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
260+
core::error::Error::source(&**self)
261+
}
262+
263+
fn provide<'a>(&'a self, req: &mut core::any::Demand<'a>) {
264+
core::error::Error::provide(&**self, req);
265+
}
266+
}
267+
268+
#[cfg(not(bootstrap))]
269+
#[stable(feature = "try_reserve", since = "1.57.0")]
270+
impl core::error::Error for crate::collections::TryReserveError {}
271+
272+
#[cfg(not(bootstrap))]
273+
#[stable(feature = "rust1", since = "1.0.0")]
274+
impl core::error::Error for crate::ffi::NulError {
275+
#[allow(deprecated)]
276+
fn description(&self) -> &str {
277+
"nul byte found in data"
278+
}
279+
}
280+
281+
#[cfg(not(bootstrap))]
282+
#[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")]
283+
impl core::error::Error for crate::ffi::FromVecWithNulError {}
284+
285+
#[cfg(not(bootstrap))]
286+
#[stable(feature = "cstring_into", since = "1.7.0")]
287+
impl core::error::Error for crate::ffi::IntoStringError {
288+
#[allow(deprecated)]
289+
fn description(&self) -> &str {
290+
"C string contained non-utf8 bytes"
291+
}
292+
293+
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
294+
Some(self.__source())
295+
}
296+
}

‎library/alloc/src/string.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444

4545
#[cfg(not(no_global_oom_handling))]
4646
use core::char::{decode_utf16, REPLACEMENT_CHARACTER};
47+
#[cfg(not(bootstrap))]
48+
use core::error::Error;
4749
use core::fmt;
4850
use core::hash;
4951
use core::iter::FusedIterator;
@@ -1938,6 +1940,24 @@ impl fmt::Display for FromUtf16Error {
19381940
}
19391941
}
19401942

1943+
#[cfg(not(bootstrap))]
1944+
#[stable(feature = "rust1", since = "1.0.0")]
1945+
impl Error for FromUtf8Error {
1946+
#[allow(deprecated)]
1947+
fn description(&self) -> &str {
1948+
"invalid utf-8"
1949+
}
1950+
}
1951+
1952+
#[cfg(not(bootstrap))]
1953+
#[stable(feature = "rust1", since = "1.0.0")]
1954+
impl Error for FromUtf16Error {
1955+
#[allow(deprecated)]
1956+
fn description(&self) -> &str {
1957+
"invalid utf-16"
1958+
}
1959+
}
1960+
19411961
#[cfg(not(no_global_oom_handling))]
19421962
#[stable(feature = "rust1", since = "1.0.0")]
19431963
impl Clone for String {

‎library/core/src/alloc/layout.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// Your performance intuition is useless. Run perf.
66

77
use crate::cmp;
8+
#[cfg(not(bootstrap))]
9+
use crate::error::Error;
810
use crate::fmt;
911
use crate::mem::{self, ValidAlign};
1012
use crate::ptr::NonNull;
@@ -436,6 +438,10 @@ pub type LayoutErr = LayoutError;
436438
#[derive(Clone, PartialEq, Eq, Debug)]
437439
pub struct LayoutError;
438440

441+
#[cfg(not(bootstrap))]
442+
#[stable(feature = "alloc_layout", since = "1.28.0")]
443+
impl Error for LayoutError {}
444+
439445
// (we need this for downstream impl of trait Error)
440446
#[stable(feature = "alloc_layout", since = "1.28.0")]
441447
impl fmt::Display for LayoutError {

‎library/core/src/alloc/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ pub use self::layout::LayoutErr;
2121
#[stable(feature = "alloc_layout_error", since = "1.50.0")]
2222
pub use self::layout::LayoutError;
2323

24+
#[cfg(not(bootstrap))]
25+
use crate::error::Error;
2426
use crate::fmt;
2527
use crate::ptr::{self, NonNull};
2628

@@ -32,6 +34,14 @@ use crate::ptr::{self, NonNull};
3234
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
3335
pub struct AllocError;
3436

37+
#[cfg(not(bootstrap))]
38+
#[unstable(
39+
feature = "allocator_api",
40+
reason = "the precise API and guarantees it provides may be tweaked.",
41+
issue = "32838"
42+
)]
43+
impl Error for AllocError {}
44+
3545
// (we need this for downstream impl of trait Error)
3646
#[unstable(feature = "allocator_api", issue = "32838")]
3747
impl fmt::Display for AllocError {

‎library/core/src/array/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use crate::borrow::{Borrow, BorrowMut};
88
use crate::cmp::Ordering;
99
use crate::convert::{Infallible, TryFrom};
10+
#[cfg(not(bootstrap))]
11+
use crate::error::Error;
1012
use crate::fmt;
1113
use crate::hash::{self, Hash};
1214
use crate::iter::TrustedLen;
@@ -119,6 +121,15 @@ impl fmt::Display for TryFromSliceError {
119121
}
120122
}
121123

124+
#[cfg(not(bootstrap))]
125+
#[stable(feature = "try_from", since = "1.34.0")]
126+
impl Error for TryFromSliceError {
127+
#[allow(deprecated)]
128+
fn description(&self) -> &str {
129+
self.__description()
130+
}
131+
}
132+
122133
impl TryFromSliceError {
123134
#[unstable(
124135
feature = "array_error_internals",

‎library/core/src/char/decode.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! UTF-8 and UTF-16 decoding iterators
22
3+
#[cfg(not(bootstrap))]
4+
use crate::error::Error;
35
use crate::fmt;
46

57
use super::from_u32_unchecked;
@@ -121,3 +123,12 @@ impl fmt::Display for DecodeUtf16Error {
121123
write!(f, "unpaired surrogate found: {:x}", self.code)
122124
}
123125
}
126+
127+
#[cfg(not(bootstrap))]
128+
#[stable(feature = "decode_utf16", since = "1.9.0")]
129+
impl Error for DecodeUtf16Error {
130+
#[allow(deprecated)]
131+
fn description(&self) -> &str {
132+
"unpaired surrogate found"
133+
}
134+
}

‎library/core/src/char/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ pub use self::methods::encode_utf16_raw;
3636
#[unstable(feature = "char_internals", reason = "exposed only for libstd", issue = "none")]
3737
pub use self::methods::encode_utf8_raw;
3838

39+
#[cfg(not(bootstrap))]
40+
use crate::error::Error;
3941
use crate::fmt::{self, Write};
4042
use crate::iter::FusedIterator;
4143

@@ -582,3 +584,7 @@ impl fmt::Display for TryFromCharError {
582584
"unicode code point out of range".fmt(fmt)
583585
}
584586
}
587+
588+
#[cfg(not(bootstrap))]
589+
#[stable(feature = "u8_from_char", since = "1.59.0")]
590+
impl Error for TryFromCharError {}

‎library/core/src/convert/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
3535
#![stable(feature = "rust1", since = "1.0.0")]
3636

37+
#[cfg(not(bootstrap))]
38+
use crate::error::Error;
3739
use crate::fmt;
3840
use crate::hash::{Hash, Hasher};
3941

@@ -715,6 +717,14 @@ impl fmt::Display for Infallible {
715717
}
716718
}
717719

720+
#[cfg(not(bootstrap))]
721+
#[stable(feature = "str_parse_error2", since = "1.8.0")]
722+
impl Error for Infallible {
723+
fn description(&self) -> &str {
724+
match *self {}
725+
}
726+
}
727+
718728
#[stable(feature = "convert_infallible", since = "1.34.0")]
719729
impl PartialEq for Infallible {
720730
fn eq(&self, _: &Infallible) -> bool {

‎library/core/src/error.rs

Lines changed: 77 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,6 @@
11
//! Interfaces for working with Errors.
2-
//!
3-
//! # Error Handling In Rust
4-
//!
5-
//! The Rust language provides two complementary systems for constructing /
6-
//! representing, reporting, propagating, reacting to, and discarding errors.
7-
//! These responsibilities are collectively known as "error handling." The
8-
//! components of the first system, the panic runtime and interfaces, are most
9-
//! commonly used to represent bugs that have been detected in your program. The
10-
//! components of the second system, `Result`, the error traits, and user
11-
//! defined types, are used to represent anticipated runtime failure modes of
12-
//! your program.
13-
//!
14-
//! ## The Panic Interfaces
15-
//!
16-
//! The following are the primary interfaces of the panic system and the
17-
//! responsibilities they cover:
18-
//!
19-
//! * [`panic!`] and [`panic_any`] (Constructing, Propagated automatically)
20-
//! * [`PanicInfo`] (Reporting)
21-
//! * [`set_hook`], [`take_hook`], and [`#[panic_handler]`][panic-handler] (Reporting)
22-
//! * [`catch_unwind`] and [`resume_unwind`] (Discarding, Propagating)
23-
//!
24-
//! The following are the primary interfaces of the error system and the
25-
//! responsibilities they cover:
26-
//!
27-
//! * [`Result`] (Propagating, Reacting)
28-
//! * The [`Error`] trait (Reporting)
29-
//! * User defined types (Constructing / Representing)
30-
//! * [`match`] and [`downcast`] (Reacting)
31-
//! * The question mark operator ([`?`]) (Propagating)
32-
//! * The partially stable [`Try`] traits (Propagating, Constructing)
33-
//! * [`Termination`] (Reporting)
34-
//!
35-
//! ## Converting Errors into Panics
36-
//!
37-
//! The panic and error systems are not entirely distinct. Often times errors
38-
//! that are anticipated runtime failures in an API might instead represent bugs
39-
//! to a caller. For these situations the standard library provides APIs for
40-
//! constructing panics with an `Error` as it's source.
41-
//!
42-
//! * [`Result::unwrap`]
43-
//! * [`Result::expect`]
44-
//!
45-
//! These functions are equivalent, they either return the inner value if the
46-
//! `Result` is `Ok` or panic if the `Result` is `Err` printing the inner error
47-
//! as the source. The only difference between them is that with `expect` you
48-
//! provide a panic error message to be printed alongside the source, whereas
49-
//! `unwrap` has a default message indicating only that you unwraped an `Err`.
50-
//!
51-
//! Of the two, `expect` is generally preferred since its `msg` field allows you
52-
//! to convey your intent and assumptions which makes tracking down the source
53-
//! of a panic easier. `unwrap` on the other hand can still be a good fit in
54-
//! situations where you can trivially show that a piece of code will never
55-
//! panic, such as `"127.0.0.1".parse::<std::net::IpAddr>().unwrap()` or early
56-
//! prototyping.
57-
//!
58-
//! # Common Message Styles
59-
//!
60-
//! There are two common styles for how people word `expect` messages. Using
61-
//! the message to present information to users encountering a panic
62-
//! ("expect as error message") or using the message to present information
63-
//! to developers debugging the panic ("expect as precondition").
64-
//!
65-
//! In the former case the expect message is used to describe the error that
66-
//! has occurred which is considered a bug. Consider the following example:
67-
//!
68-
//! ```should_panic
69-
//! // Read environment variable, panic if it is not present
70-
//! let path = std::env::var("IMPORTANT_PATH").unwrap();
71-
//! ```
72-
//!
73-
//! In the "expect as error message" style we would use expect to describe
74-
//! that the environment variable was not set when it should have been:
75-
//!
76-
//! ```should_panic
77-
//! let path = std::env::var("IMPORTANT_PATH")
78-
//! .expect("env variable `IMPORTANT_PATH` is not set");
79-
//! ```
80-
//!
81-
//! In the "expect as precondition" style, we would instead describe the
82-
//! reason we _expect_ the `Result` should be `Ok`. With this style we would
83-
//! prefer to write:
84-
//!
85-
//! ```should_panic
86-
//! let path = std::env::var("IMPORTANT_PATH")
87-
//! .expect("env variable `IMPORTANT_PATH` should be set by `wrapper_script.sh`");
88-
//! ```
89-
//!
90-
//! The "expect as error message" style does not work as well with the
91-
//! default output of the std panic hooks, and often ends up repeating
92-
//! information that is already communicated by the source error being
93-
//! unwrapped:
94-
//!
95-
//! ```text
96-
//! thread 'main' panicked at 'env variable `IMPORTANT_PATH` is not set: NotPresent', src/main.rs:4:6
97-
//! ```
98-
//!
99-
//! In this example we end up mentioning that an env variable is not set,
100-
//! followed by our source message that says the env is not present, the
101-
//! only additional information we're communicating is the name of the
102-
//! environment variable being checked.
103-
//!
104-
//! The "expect as precondition" style instead focuses on source code
105-
//! readability, making it easier to understand what must have gone wrong in
106-
//! situations where panics are being used to represent bugs exclusively.
107-
//! Also, by framing our expect in terms of what "SHOULD" have happened to
108-
//! prevent the source error, we end up introducing new information that is
109-
//! independent from our source error.
110-
//!
111-
//! ```text
112-
//! thread 'main' panicked at 'env variable `IMPORTANT_PATH` should be set by `wrapper_script.sh`: NotPresent', src/main.rs:4:6
113-
//! ```
114-
//!
115-
//! In this example we are communicating not only the name of the
116-
//! environment variable that should have been set, but also an explanation
117-
//! for why it should have been set, and we let the source error display as
118-
//! a clear contradiction to our expectation.
119-
//!
120-
//! **Hint**: If you're having trouble remembering how to phrase
121-
//! expect-as-precondition style error messages remember to focus on the word
122-
//! "should" as in "env variable should be set by blah" or "the given binary
123-
//! should be available and executable by the current user".
124-
//!
125-
//! [`panic_any`]: crate::panic::panic_any
126-
//! [`PanicInfo`]: crate::panic::PanicInfo
127-
//! [`catch_unwind`]: crate::panic::catch_unwind
128-
//! [`resume_unwind`]: crate::panic::resume_unwind
129-
//! [`downcast`]: crate::error::Error
130-
//! [`Termination`]: crate::process::Termination
131-
//! [`Try`]: crate::ops::Try
132-
//! [panic hook]: crate::panic::set_hook
133-
//! [`set_hook`]: crate::panic::set_hook
134-
//! [`take_hook`]: crate::panic::take_hook
135-
//! [panic-handler]: <https://doc.rust-lang.org/nomicon/panic-handler.html>
136-
//! [`match`]: ../../std/keyword.match.html
137-
//! [`?`]: ../../std/result/index.html#the-question-mark-operator-
2+
// FIXME(yaahc): link to std docs or common docs and try to figure out intradoc issue
3+
#![unstable(feature = "error_in_core", issue = "none")]
1384

1395
// A note about crates and the facade:
1406
//
@@ -563,3 +429,78 @@ impl<'a> Iterator for Chain<'a> {
563429
current
564430
}
565431
}
432+
433+
#[stable(feature = "error_by_ref", since = "1.51.0")]
434+
impl<'a, T: Error + ?Sized> Error for &'a T {
435+
#[allow(deprecated, deprecated_in_future)]
436+
fn description(&self) -> &str {
437+
Error::description(&**self)
438+
}
439+
440+
#[allow(deprecated)]
441+
fn cause(&self) -> Option<&dyn Error> {
442+
Error::cause(&**self)
443+
}
444+
445+
fn source(&self) -> Option<&(dyn Error + 'static)> {
446+
Error::source(&**self)
447+
}
448+
449+
fn provide<'b>(&'b self, req: &mut Demand<'b>) {
450+
Error::provide(&**self, req);
451+
}
452+
}
453+
454+
#[stable(feature = "fmt_error", since = "1.11.0")]
455+
impl Error for crate::fmt::Error {
456+
#[allow(deprecated)]
457+
fn description(&self) -> &str {
458+
"an error occurred when formatting an argument"
459+
}
460+
}
461+
462+
#[stable(feature = "try_borrow", since = "1.13.0")]
463+
impl Error for crate::cell::BorrowError {
464+
#[allow(deprecated)]
465+
fn description(&self) -> &str {
466+
"already mutably borrowed"
467+
}
468+
}
469+
470+
#[stable(feature = "try_borrow", since = "1.13.0")]
471+
impl Error for crate::cell::BorrowMutError {
472+
#[allow(deprecated)]
473+
fn description(&self) -> &str {
474+
"already borrowed"
475+
}
476+
}
477+
478+
#[stable(feature = "try_from", since = "1.34.0")]
479+
impl Error for crate::char::CharTryFromError {
480+
#[allow(deprecated)]
481+
fn description(&self) -> &str {
482+
"converted integer out of range for `char`"
483+
}
484+
}
485+
486+
#[stable(feature = "char_from_str", since = "1.20.0")]
487+
impl Error for crate::char::ParseCharError {
488+
#[allow(deprecated)]
489+
fn description(&self) -> &str {
490+
self.__description()
491+
}
492+
}
493+
494+
#[unstable(feature = "duration_checked_float", issue = "83400")]
495+
impl Error for crate::time::FromFloatSecsError {}
496+
497+
#[stable(feature = "frombyteswithnulerror_impls", since = "1.17.0")]
498+
impl Error for crate::ffi::FromBytesWithNulError {
499+
#[allow(deprecated)]
500+
fn description(&self) -> &str {
501+
self.__description()
502+
}
503+
}
504+
505+
#[unstable(feature = "cstr_from_bytes_until_nul", issue = "95027")]
506+
impl Error for crate::ffi::FromBytesUntilNulError {}

‎library/core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ pub mod cmp;
303303
pub mod convert;
304304
pub mod default;
305305
#[cfg(not(bootstrap))]
306-
#[unstable(feature = "error_in_core", issue = "none")]
307306
pub mod error;
308307
pub mod marker;
309308
pub mod ops;

‎library/core/src/num/error.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! Error types for conversion to integral types.
22
33
use crate::convert::Infallible;
4+
#[cfg(not(bootstrap))]
5+
use crate::error::Error;
46
use crate::fmt;
57

68
/// The error type returned when a checked integral type conversion fails.
@@ -144,3 +146,21 @@ impl fmt::Display for ParseIntError {
144146
self.__description().fmt(f)
145147
}
146148
}
149+
150+
#[cfg(not(bootstrap))]
151+
#[stable(feature = "rust1", since = "1.0.0")]
152+
impl Error for ParseIntError {
153+
#[allow(deprecated)]
154+
fn description(&self) -> &str {
155+
self.__description()
156+
}
157+
}
158+
159+
#[cfg(not(bootstrap))]
160+
#[stable(feature = "try_from", since = "1.34.0")]
161+
impl Error for TryFromIntError {
162+
#[allow(deprecated)]
163+
fn description(&self) -> &str {
164+
self.__description()
165+
}
166+
}

‎library/core/src/num/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#![stable(feature = "rust1", since = "1.0.0")]
44

55
use crate::ascii;
6+
#[cfg(not(bootstrap))]
7+
use crate::error::Error;
68
use crate::intrinsics;
79
use crate::mem;
810
use crate::ops::{Add, Mul, Sub};
@@ -57,6 +59,15 @@ pub use wrapping::Wrapping;
5759
#[cfg(not(no_fp_fmt_parse))]
5860
pub use dec2flt::ParseFloatError;
5961

62+
#[cfg(not(bootstrap))]
63+
#[stable(feature = "rust1", since = "1.0.0")]
64+
impl Error for ParseFloatError {
65+
#[allow(deprecated)]
66+
fn description(&self) -> &str {
67+
self.__description()
68+
}
69+
}
70+
6071
#[stable(feature = "rust1", since = "1.0.0")]
6172
pub use error::ParseIntError;
6273

‎library/core/src/str/error.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Defines utf8 error type.
22
3+
#[cfg(not(bootstrap))]
4+
use crate::error::Error;
35
use crate::fmt;
46

57
/// Errors which can occur when attempting to interpret a sequence of [`u8`]
@@ -122,6 +124,15 @@ impl fmt::Display for Utf8Error {
122124
}
123125
}
124126

127+
#[cfg(not(bootstrap))]
128+
#[stable(feature = "rust1", since = "1.0.0")]
129+
impl Error for Utf8Error {
130+
#[allow(deprecated)]
131+
fn description(&self) -> &str {
132+
"invalid utf-8: corrupt contents"
133+
}
134+
}
135+
125136
/// An error returned when parsing a `bool` using [`from_str`] fails
126137
///
127138
/// [`from_str`]: super::FromStr::from_str
@@ -136,3 +147,12 @@ impl fmt::Display for ParseBoolError {
136147
"provided string was not `true` or `false`".fmt(f)
137148
}
138149
}
150+
151+
#[cfg(not(bootstrap))]
152+
#[stable(feature = "rust1", since = "1.0.0")]
153+
impl Error for ParseBoolError {
154+
#[allow(deprecated)]
155+
fn description(&self) -> &str {
156+
"failed to parse bool"
157+
}
158+
}

‎library/std/src/collections/hash/map.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ use crate::borrow::Borrow;
99
use crate::cell::Cell;
1010
use crate::collections::TryReserveError;
1111
use crate::collections::TryReserveErrorKind;
12+
#[cfg(not(bootstrap))]
13+
use crate::error::Error;
1214
use crate::fmt::{self, Debug};
1315
#[allow(deprecated)]
1416
use crate::hash::{BuildHasher, Hash, Hasher, SipHasher13};
@@ -2158,6 +2160,15 @@ impl<'a, K: Debug, V: Debug> fmt::Display for OccupiedError<'a, K, V> {
21582160
}
21592161
}
21602162

2163+
#[cfg(not(bootstrap))]
2164+
#[unstable(feature = "map_try_insert", issue = "82766")]
2165+
impl<'a, K: fmt::Debug, V: fmt::Debug> Error for OccupiedError<'a, K, V> {
2166+
#[allow(deprecated)]
2167+
fn description(&self) -> &str {
2168+
"key already exists"
2169+
}
2170+
}
2171+
21612172
#[stable(feature = "rust1", since = "1.0.0")]
21622173
impl<'a, K, V, S> IntoIterator for &'a HashMap<K, V, S> {
21632174
type Item = (&'a K, &'a V);

‎library/std/src/error.rs

Lines changed: 586 additions & 540 deletions
Large diffs are not rendered by default.

‎library/std/src/io/error.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ impl fmt::Debug for Error {
7676
}
7777
}
7878

79+
#[cfg(not(bootstrap))]
80+
#[stable(feature = "rust1", since = "1.0.0")]
81+
impl From<alloc::ffi::NulError> for Error {
82+
/// Converts a [`alloc::ffi::NulError`] into a [`io::Error`].
83+
fn from(_: alloc::ffi::NulError) -> Error {
84+
const_io_error!(ErrorKind::InvalidInput, "data provided contains a nul byte")
85+
}
86+
}
87+
7988
// Only derive debug in tests, to make sure it
8089
// doesn't accidentally get printed.
8190
#[cfg_attr(test, derive(Debug))]

‎library/std/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@
271271
#![feature(duration_constants)]
272272
#![cfg_attr(not(bootstrap), feature(error_generic_member_access))]
273273
#![cfg_attr(not(bootstrap), feature(error_in_core))]
274+
#![cfg_attr(not(bootstrap), feature(error_iter))]
274275
#![feature(exact_size_is_empty)]
275276
#![feature(exclusive_wrapper)]
276277
#![feature(extend_one)]

0 commit comments

Comments
 (0)
Please sign in to comment.