summary refs log tree commit diff
path: root/library/std/src/error.rs
AgeCommit message (Collapse)AuthorLines
2021-03-04Add tracking issue for map_try_insert.Mara Bos-2/+2
2021-03-04Implement Error for OccupiedError.Mara Bos-0/+18
2021-02-22Add impl `Error` for `Arc`Richard Dodd-0/+22
2021-01-24Rollup merge of #75180 - KodrAus:feat/error-by-ref, r=m-ou-seJonas Schievink-0/+21
Implement Error for &(impl Error) Opening this up just to see what it breaks. It's unfortunate that `&(impl Error)` doesn't actually implement `Error`. If this direct approach doesn't work out then I'll try something different, like an `Error::by_ref` method. **EDIT:** This is a super low-priority experiment so feel free to cancel it for more important crater runs! 🙂 ----- # Stabilization Report ## Why? We've been working for the last few years to try "fix" the `Error` trait, which is probably one of the most fundamental in the whole standard library. One of its issues is that we commonly expect you to work with abstract errors through `dyn Trait`, but references and smart pointers over `dyn Trait` don't actually implement the `Error` trait. If you have a `&dyn Error` or a `Box<dyn Error>` you simply can't pass it to a method that wants a `impl Error`. ## What does this do? This stabilizes the following trait impl: ```rust impl<'a, T: Error + ?Sized + 'static> Error for &'a T; ``` This means that `&dyn Error` will now satisfy a `impl Error` bound. It doesn't do anything with `Box<dyn Error>` directly. We discussed how we could do `Box<dyn Error>` in the thread here (and elsewhere in the past), but it seems like we need something like lattice-based specialization or a sprinkling of snowflake compiler magic to make that work. Having said that, with this new impl you _can_ now get a `impl Error` from a `Box<dyn Error>` by dereferencing it. ## What breaks? A crater run revealed a few crates broke with something like the following: ```rust // where e: &'short &'long dyn Error err.source() ``` previously we'd auto-deref that `&'short &'long dyn Error` to return a `Option<&'long dyn Error>` from `source`, but now will call directly on `&'short impl Error`, so will return a `Option<&'short dyn Error>`. The fix is to manually deref: ```rust // where e: &'short &'long dyn Error (*err).source() ``` In the recent Libs meeting we considered this acceptable breakage.
2020-12-31Remove many unnecessary manual link resolves from libraryCamelid-2/+0
Now that #76934 has merged, we can remove a lot of these! E.g, this is no longer necessary: [`Vec<T>`]: Vec
2020-12-21bump stabilization to 1.51.0Ashley Mannix-1/+1
2020-10-31update stabilization to 1.49.0Ashley Mannix-1/+1
2020-10-08Rename LayoutErr to LayoutError outside of coreJacob Hughes-2/+2
2020-09-28Rename AllocErr to AllocErrorJacob Hughes-2/+2
2020-09-11Mark Error impl for LayoutErr as stable.Mara Bos-5/+1
This impl was effectively stable. #[unstable] had no effect here, since both Error and LayoutErr were already stable. This effectively became stable as soon as LayoutErr became stable, which was in 1.28.0.
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-41/+3
Also doing fmt inplace as requested.
2020-08-27Reduce duplicate doc link in errorIvan Tham-1/+1
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-26Use [xxx()] rather than the [xxx] functionIvan Tham-2/+2
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-26Error use explicit intra-doc link and fix textIvan Tham-10/+7
2020-08-23Convert str -> prim@str in `std`Joshua Nelson-0/+4
2020-08-17Switch to intra-doc links for std/src/error.rsEllen-25/+3
2020-08-05implement Error for &(impl Error)Ashley Mannix-0/+21
2020-07-27mv std libs to library/mark-0/+802