-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std: Stabilize last bits of io::Error #23919
Conversation
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
cc @seanmonstar |
7df7210
to
a1a03d4
Compare
👍 |
This commit stabilizes a few remaining bits of the `io::Error` type: * The `Error::new` method is now stable. The last `detail` parameter was removed and the second `desc` parameter was generalized to `E: Into<Box<Error>>` to allow creating an I/O error from any form of error. Currently there is no form of downcasting, but this will be added in time. * An implementation of `From<&str> for Box<Error>` was added to liballoc to allow construction of errors from raw strings. * The `Error::raw_os_error` method was stabilized as-is. * Trait impls for `Clone`, `Eq`, and `PartialEq` were removed from `Error` as it is not possible to use them with trait objects. This is a breaking change due to the modification of the `new` method as well as the removal of the trait implementations for the `Error` type. [breaking-change]
@@ -162,8 +177,7 @@ impl Error { | |||
/// | |||
/// If this `Error` was constructed via `last_os_error` then this function | |||
/// will return `Some`, otherwise it will return `None`. | |||
#[unstable(feature = "io", reason = "function was just added and the return \ | |||
type may become an abstract OS error")] | |||
#[unstable(feature = "rust1", since = "1.0.0")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think you wanted stable
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I do!
a1a03d4
to
ac77392
Compare
Ah this is also a breaking change as |
r=me modulo nits |
Conflicts: src/libstd/fs/tempdir.rs src/libstd/io/error.rs
\o/ |
As per rust-lang/rust#23919, the last argument was removed from Error::new. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
As per rust-lang/rust#23919, the last argument was removed from Error::new, and the Clone, Eq, and PartialEq traits were removed from Error. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
As per rust-lang/rust#23919, the Clone and PartialEq traits were removed from io::Error, breaking the derived Clone and PartialEq trait of ParserError. Use Rc<io::Error> to get Clone back, and implement PartialEq manually. [breaking-change] Signed-off-by: Anders Kaseorg <andersk@mit.edu>
As per rust-lang/rust#23919, the last argument was removed from Error::new. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
As per rust-lang/rust#23919, the PartialEq trait was removed from Error. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
As per rust-lang/rust#23919, the last argument was removed from Error::new, and the Clone, Eq, and PartialEq traits were removed from Error. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
As per rust-lang/rust#23919, the Clone and PartialEq traits were removed from io::Error, breaking the derived Clone and PartialEq trait of ParserError. Use Rc<io::Error> to get Clone back, and implement PartialEq manually. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
As per rust-lang/rust#23919, the last argument was removed from Error::new. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
As per rust-lang/rust#23919, the last argument was removed from Error::new, and the Clone, Eq, and PartialEq traits were removed from Error. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This is rather unfortunate. I was relying on The only solution I can see is to change my API to start returning Is there no way that |
Yeah I agree that this had more fallout than I initially realized. There may be a few possible routes for your API, however. In general I'd recommend avoiding
Unfortunately cloning |
Ah right, I forgot about that. Why do we have that limitation? I get why a trait that uses
It could use At the moment I'm thinking the best solution is actually just to make As for your other suggestions, I'm not generating the Some tangential musing about the returning- I would think this could be supported for functions that return Although in the future if we do support All of this assumes, of course, that we continue to not have "real" subtyping. If we did, this wouldn't work as a a |
I came up with a workaround, which is to create my own type that contains an |
I find the use case of putting |
As per rust-lang/rust#23919, the Clone and PartialEq traits were removed from io::Error, breaking the derived Clone and PartialEq trait of ParserError. Use Rc<io::Error> to get Clone back, and implement PartialEq manually. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
As per rust-lang/rust#23919, the Clone and PartialEq traits were removed from io::Error, breaking the derived Clone and PartialEq trait of ParserError. Use Rc<io::Error> to get Clone back, and implement PartialEq manually. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit stabilizes a few remaining bits of the
io::Error
type:Error::new
method is now stable. The lastdetail
parameter was removedand the second
desc
parameter was generalized toE: Into<Box<Error>>
toallow creating an I/O error from any form of error. Currently there is no form
of downcasting, but this will be added in time.
From<&str> for Box<Error>
was added to liballoc toallow construction of errors from raw strings.
Error::raw_os_error
method was stabilized as-is.Clone
,Eq
, andPartialEq
were removed fromError
as itis not possible to use them with trait objects.
This is a breaking change due to the modification of the
new
method as well asthe removal of the trait implementations for the
Error
type.[breaking-change]