about summary refs log tree commit diff
path: root/src/libstd/error.rs
AgeCommit message (Collapse)AuthorLines
2020-03-26Overhaul of the `AllocRef` trait to match allocator-wg's latest consensTim Diekmann-8/+1
2020-03-21Fix deprecated Error.description() usage in docsMarti Raudsepp-1/+1
2020-03-12Rollup merge of #69792 - LenaWil:try_reserve_error/impl-error, r=sfacklerMazdak Farrokhzad-0/+3
Implement Error for TryReserveError I noticed that the Error trait wasn't implemented for TryReserveError. (#48043) Not sure if the error messages and code style are 100% correct, it's my first time contributing to the Rust std.
2020-03-10Remove deprecated description function of TryReserveErrorLena Wildervanck-5/+1
2020-03-07Implement Error for TryReserveErrorLena Wildervanck-0/+7
2020-03-05Update deprecation version to 1.42 for Error::descriptionDylan Nugent-1/+1
Error::description is deprecated as of version 1.42, as the commit was not in the release for 1.41.
2020-01-10inline `impl From<String> for Box<dyn Error + Send + Sync>`Lzu Tao-0/+2
2019-12-24Deprecate Error::description for realDavid Tolnay-116/+44
`description` has been documented as soft-deprecated since 1.27.0 (17 months ago). There is no longer any reason to call it or implement it. This commit: - adds #[rustc_deprecated(since = "1.41.0")] to Error::description; - moves description (and cause, which is also deprecated) below the source and backtrace methods in the Error trait; - reduces documentation of description and cause to take up much less vertical real estate in rustdocs, while preserving the example that shows how to render errors without needing to call description; - removes the description function of all *currently unstable* Error impls in the standard library; - marks #[allow(deprecated)] the description function of all *stable* Error impls in the standard library; - replaces miscellaneous uses of description in example code and the compiler.
2019-12-24Rollup merge of #67561 - euclio:remove-description, r=jonas-schievinkMazdak Farrokhzad-28/+4
remove `description` from `Error` impls in docs Since `description` is soft-deprecated, there's no need to show it implemented in these examples.
2019-12-23remove `description` from `Error` impls in docsAndy Russell-28/+4
2019-12-22Format the worldMark Rousskov-35/+53
2019-12-14Revert "Stabilize the `never_type`, written `!`."Niko Matsakis-1/+1
This reverts commit 15c30ddd69d6cc3fffe6d304c6dc968a5ed046f1.
2019-12-14Revert "Redefine `core::convert::Infallible` as `!`."Niko Matsakis-0/+7
This reverts commit 089229a1935fa9795cfdefa518c8f8c3beb66db8.
2019-11-26Fix spelling typosBrian Wignall-1/+1
2019-11-21Redefine `core::convert::Infallible` as `!`.Mazdak Farrokhzad-7/+0
2019-11-21Stabilize the `never_type`, written `!`.Mazdak Farrokhzad-1/+1
2019-11-18std::error::Chain: remove CopyHarald Hoyer-1/+1
remove Copy from Iterator as per comment https://github.com/rust-lang/rust/issues/58520#issuecomment-553682166
2019-10-22rename Error::iter_chain() and remove Error::iter_sources()Harald Hoyer-80/+12
Rename * Error::iter_chain() -> Error::chain() * ErrorIter -> Chain Removed * Error::iter_sources() according to https://github.com/rust-lang/rust/issues/58520 Rationale: 1. Such iterators are helpful. They should better be stabilized sooner than later. 2. self should be included. It is easy to .skip(1) it. Not including self is harmful because it is harder to add self to the iterator than to remove it. 3. The chosen name should be telling and reflect the fact that self is included. `.chain()` was chosen because the iterator iterates over the chain of errors that is somehow included in self. 4. The resulting iterator is named `Chain` because the `error::Chain` is what we want to have.
2019-10-13Fix typos in error.rsBO41-5/+5
2019-09-14Rollup merge of #64203 - alexreg:rush-pr-2, r=centrilMazdak Farrokhzad-17/+17
A few cosmetic improvements to code & comments in liballoc and libcore Factored out from hacking on rustc for work on the REPL. r? @Centril
2019-09-09std: Add a `backtrace` moduleAlex Crichton-0/+15
This commit adds a `backtrace` module to the standard library, as designed in [RFC 2504]. The `Backtrace` type is intentionally very conservative, effectively only allowing capturing it and printing it. Additionally this commit also adds a `backtrace` method to the `Error` trait which defaults to returning `None`, as specified in [RFC 2504]. More information about the design here can be found in [RFC 2504] and in the [tracking issue]. Implementation-wise this is all based on the `backtrace` crate and very closely mirrors the `backtrace::Backtrace` type on crates.io. Otherwise it's pretty standard in how it handles everything internally. [RFC 2504]: https://github.com/rust-lang/rfcs/blob/master/text/2504-fix-error.md [tracking issue]: https://github.com/rust-lang/rust/issues/53487 cc #53487
2019-09-06A few cosmetic improvements to code & comments in liballoc and libcoreAlexander Regueiro-17/+17
2019-07-26Introduce built-in macros through libcoreVadim Petrochenkov-5/+5
2019-06-17implement Error::source for Box<T: Error>s3bk-0/+4
fixes https://github.com/rust-lang/rust/issues/61899
2019-05-31Rollup merge of #60897 - seanmonstar:patch-4, r=sfacklerPietro Albini-1/+7
error: remove StringError from Debug output Seeing `StringError("something something")` in debug output can cause someone to think there was an error dealing with `String`s, not that the error type is just a string. So, remove that noise. For example: ``` io error: Custom { kind: InvalidData, error: StringError("corrupt data") } ``` With this change: ``` io error: Custom { kind: InvalidData, error: "corrupt data" } ```
2019-05-29Update libstd doctests to use dynmemoryruins-9/+9
2019-05-20Rollup merge of #60511 - taiki-e:libstd-intra-doc, r=Dylan-DPCMazdak Farrokhzad-0/+18
Fix intra-doc link resolution failure on re-exporting libstd Currently, re-exporting libstd items as below will [occur a lot of failures](https://gist.github.com/taiki-e/e33e0e8631ef47f65a74a3b69f456366). ```rust pub use std::*; ``` Until the underlying issue (#56922) fixed, we can fix that so they don't propagate to downstream crates. Related: https://github.com/rust-lang/rust/pull/56941 (That PR fixed failures that occur when re-exporting from libcore to libstd.) r? @QuietMisdreavus
2019-05-16Update src/libstd/error.rsSteven Fackler-1/+1
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-05-16Prevent Error::type_id overridesSteven Fackler-2/+10
type_id now takes an argument that can't be named outside of the std::error module, which prevents any implementations from overriding it. It's a pretty grody solution, and there's no way we can stabilize the method with this API, but it avoids the soudness issue! Closes #60784
2019-05-16error: remove StringError from Debug outputSean McArthur-1/+7
Seeing `StringError("something something")` in debug output can cause someone to think there was an error dealing with `String`s, not that the error type is just a string. So, remove that noise.
2019-05-13Destabilize the `Error::type_id` functionAlex Crichton-1/+4
This commit destabilizes the `Error::type_id` function in the standard library. This does so by effectively reverting #58048, restoring the `#[unstable]` attribute. The security mailing list has recently been notified of a vulnerability relating to the stabilization of this function. First stabilized in Rust 1.34.0, a stable function here allows users to implement a custom return value for this function: struct MyType; impl Error for MyType { fn type_id(&self) -> TypeId { // Enable safe casting to `String` by accident. TypeId::of::<String>() } } This, when combined with the `Error::downcast` family of functions, allows safely casting a type to any other type, clearly a memory safety issue! A security announcement will be shortly posted to the security mailing list as well as the Rust Blog, and when those links are available they'll be filled in for this PR as well. This commit simply destabilizes the `Error::type_id` which, although breaking for users since Rust 1.34.0, is hoped to have little impact and has been deemed sufficient to mitigate this issue for the stable channel. The long-term fate of the `Error::type_id` API will be discussed at #60784.
2019-05-04Fix intra-doc link resolution failure on re-exporting libstdTaiki Endo-0/+18
2019-03-31Rollup merge of #59587 - XAMPPRocky:master, r=CentrilMazdak Farrokhzad-1/+0
Remove #[doc(hidden)] from Error::type_id Nominating this for beta so that `Error::type_id` has documentation in time for release. cc @rust-lang/release @rust-lang/docs
2019-03-31Remove #[doc(hidden)] from Error::type_idAaron Power-1/+0
2019-03-31libstd: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-16/+16
2019-03-09Use lifetime contravariance to elide more lifetimes in core+alloc+stdScott McMurray-4/+4
2019-02-28libstd => 2018Taiki Endo-11/+12
2019-02-25Auto merge of #58302 - SimonSapin:tryfrom, r=alexcrichtonbors-3/+3
Stabilize TryFrom and TryInto with a convert::Infallible empty enum This is the plan proposed in https://github.com/rust-lang/rust/issues/33417#issuecomment-423073898
2019-02-16Fix tracking issue for error iteratorsSteven Fackler-4/+4
2019-02-13Stabilize TryFrom and TryIntoSimon Sapin-3/+3
2019-02-13Rollup merge of #58289 - haraldh:master, r=sfacklerMazdak Farrokhzad-0/+152
impl iter() for dyn Error Examples: ```rust let next_error_type_a = err .iter() .filter_map(Error::downcast_ref::<ErrorTypeA>) .next(); ``` ```rust let source_root_error = err.iter().last(); ``` Credit for the ErrorIter goes to reddit user /u/tdiekmann (Tim Diekmann) https://www.reddit.com/r/rust/comments/aj3lpg/is_an_iterator_impl_over_errorsource_possible/
2019-02-10libs: doc commentsAlexander Regueiro-2/+2
2019-02-09impl iter_sources() and iter_chain() for dyn ErrorHarald Hoyer-0/+152
Examples: ```rust let next_error_type_a = err .iter_chain() .filter_map(Error::downcast_ref::<ErrorTypeA>) .next(); ``` ```rust let source_root_error = err.iter_chain().last(); ``` Credit for the ErrorIter goes to Tim Diekmann https://www.reddit.com/r/rust/comments/aj3lpg/is_an_iterator_impl_over_errorsource_possible/
2019-02-01Stabilize std::error::Error::type_idSimon Sapin-3/+1
This should have been part of https://github.com/rust-lang/rust/pull/57834 FCP: https://github.com/rust-lang/rust/issues/27745#issuecomment-373906749
2019-01-08Change std::error::Error trait documentation to talk about `source` instead ↵Czipperz-7/+7
of `cause`
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-12Bump to 1.33.0Alex Crichton-0/+1
* Update bootstrap compiler * Update version to 1.33.0 * Remove some `#[cfg(stage0)]` annotations Actually updating the version number is blocked on updating Cargo
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-2/+2
2018-10-04Rollup merge of #53523 - phungleson:fix-impl-from-for-std-error, ↵Pietro Albini-0/+141
r=GuillaumeGomez Add doc for impl From for Std Error As part of issue #51430 (cc @skade). I am not sure if it is going to a correct direction so put up here so that people can comment.
2018-10-03Remove main() in examplesSon-46/+30