Skip to content
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: Stablize io::ErrorKind #23430

Merged
merged 1 commit into from
Mar 19, 2015
Merged

std: Stablize io::ErrorKind #23430

merged 1 commit into from
Mar 19, 2015

Conversation

alexcrichton
Copy link
Member

This commit stabilizes the ErrorKind enumeration which is consumed by and
generated by the io::Error type. The purpose of this type is to serve as a
cross-platform namespace to categorize errors into. Two specific issues are
addressed as part of this stablization:

  • The naming of each variant was scrutinized and some were tweaked. An example
    is how FileNotFound was renamed to simply NotFound. These names should not
    show either a Unix or Windows bias and the set of names is intended to grow
    over time. For now the names will likely largely consist of those errors
    generated by the I/O APIs in the standard library.
  • The mapping of OS error codes onto kinds has been altered. Coalescing no
    longer occurs (multiple error codes become one kind). It is intended that each
    OS error code, if bound, corresponds to only one ErrorKind. The current set
    of error kinds was expanded slightly to include some networking errors.

This commit also adds a raw_os_error function which returns an Option<i32>
to extract the underlying raw error code from the Error.

Closes #16666

[breaking-change]

@rust-highfive
Copy link
Collaborator

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@huonw huonw mentioned this pull request Mar 17, 2015
10 tasks
@alexcrichton
Copy link
Member Author

r? @aturon

@rust-highfive rust-highfive assigned aturon and unassigned brson Mar 17, 2015
@huonw
Copy link
Member

huonw commented Mar 17, 2015

Hm, stability hack: we could stop exhaustive matching in stable code by including an unstable "junk" variant.

enum ErrorKind {
     ...
     #[stable]
     Other
     #[unstable]
     Nonexhaustive
}

Thoughts?

@aturon
Copy link
Member

aturon commented Mar 17, 2015

@huonw That's not a bad idea, but it's also very difficult to imagine anyone exhaustively matching in practice, so I'm also ok just waiting for extensible enums.

@alexcrichton Do you want to add a comment saying that the set of kinds can grow over time? Otherwise r=me

@alexcrichton
Copy link
Member Author

Hm, that's not a bad idea. I wouldn't want the unstable variant to exist until the end of time, but we may get extensible enums at some point in the future which would obsolete the need for the variant, so I'd be comfortable with that.

@alexcrichton
Copy link
Member Author

I ended up adding a #[doc(hidden)] + #[unstable] variant, and we could always jettison the one unstable variant at any time.

@alexcrichton
Copy link
Member Author

@bors: r=aturon 11ec674

@bors
Copy link
Contributor

bors commented Mar 18, 2015

⌛ Testing commit 11ec674 with merge c3760e7...

@bors
Copy link
Contributor

bors commented Mar 18, 2015

💔 Test failed - auto-mac-64-nopt-t

@alexcrichton
Copy link
Member Author

@bors: r=aturon

@bors
Copy link
Contributor

bors commented Mar 18, 2015

📌 Commit 8835ea9 has been approved by aturon

@Manishearth
Copy link
Member

@bors: p=1

(not included in rollup (accident), might as well prioritize it over the other rolled up PRs)

@bors
Copy link
Contributor

bors commented Mar 19, 2015

⌛ Testing commit 8835ea9 with merge a82a9fd...

@bors
Copy link
Contributor

bors commented Mar 19, 2015

💔 Test failed - auto-win-64-opt

This commit stabilizes the `ErrorKind` enumeration which is consumed by and
generated by the `io::Error` type. The purpose of this type is to serve as a
cross-platform namespace to categorize errors into. Two specific issues are
addressed as part of this stablization:

* The naming of each variant was scrutinized and some were tweaked. An example
  is how `FileNotFound` was renamed to simply `NotFound`. These names should not
  show either a Unix or Windows bias and the set of names is intended to grow
  over time. For now the names will likely largely consist of those errors
  generated by the I/O APIs in the standard library.

* The mapping of OS error codes onto kinds has been altered. Coalescing no
  longer occurs (multiple error codes become one kind). It is intended that each
  OS error code, if bound, corresponds to only one `ErrorKind`. The current set
  of error kinds was expanded slightly to include some networking errors.

This commit also adds a `raw_os_error` function which returns an `Option<i32>`
to extract the underlying raw error code from the `Error`.
@alexcrichton
Copy link
Member Author

@bors: r=aturon dedac5e

@bors
Copy link
Contributor

bors commented Mar 19, 2015

⌛ Testing commit dedac5e with merge 7f53b94...

bors added a commit that referenced this pull request Mar 19, 2015
This commit stabilizes the `ErrorKind` enumeration which is consumed by and
generated by the `io::Error` type. The purpose of this type is to serve as a
cross-platform namespace to categorize errors into. Two specific issues are
addressed as part of this stablization:

* The naming of each variant was scrutinized and some were tweaked. An example
  is how `FileNotFound` was renamed to simply `NotFound`. These names should not
  show either a Unix or Windows bias and the set of names is intended to grow
  over time. For now the names will likely largely consist of those errors
  generated by the I/O APIs in the standard library.

* The mapping of OS error codes onto kinds has been altered. Coalescing no
  longer occurs (multiple error codes become one kind). It is intended that each
  OS error code, if bound, corresponds to only one `ErrorKind`. The current set
  of error kinds was expanded slightly to include some networking errors.

This commit also adds a `raw_os_error` function which returns an `Option<i32>`
to extract the underlying raw error code from the `Error`.

Closes #16666

[breaking-change]
@bors bors merged commit dedac5e into rust-lang:master Mar 19, 2015
willem66745 added a commit to willem66745/ntpclient-rust that referenced this pull request Mar 20, 2015
Reintroduces use of unstable features, though a number of them are
stabilized in fix rust-lang/rust#23430
@alexcrichton alexcrichton deleted the io-error branch March 20, 2015 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add WouldBlock error kind to IoError
7 participants