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

Errorkind reorder #88298

Merged
merged 3 commits into from
Aug 25, 2021
Merged

Errorkind reorder #88298

merged 3 commits into from
Aug 25, 2021

Conversation

ijackson
Copy link
Contributor

I was doing a bit more work in this area and the untidiness of these two orderings bothered me.

The commit messages have the detailed rationale. For your convenience, I c&p them here:

    io::ErrorKind: rationalise ordering in main enum
    
    It is useful to keep some coherent structure to this ordering.  In
    particular, Other and Uncategorized should be next to each other, at
    the end.
    
    Also it seems to make sense to treat UnexpectedEof and OutOfMemory
    specially, since they are not like the other errors (despite
    OutOfMemory also being generatable by some OS errors).
    
    So:
     * Move Other to the end, just before Uncategorized
     * Move Unsupported to between Interrupted and UnexpectedEof
     * Add some comments documenting where to add things
    io::Error: alphabeticise the match in as_str()
    
    There was no rationale for the previous ordering.

r? kennytm since that's who rust-highfive picked before, in #88294 which I accidentally closed.

There was no rationale for the previous ordering.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
It is useful to keep some coherent structure to this ordering.  In
particular, Other and Uncategorized should be next to each other, at
the end.

Also it seems to make sense to treat UnexpectedEof and OutOfMemory
specially, since they are not like the other errors (despite
OutOfMemory also being generatable by some OS errors).

So:
 * Move Other to the end, just before Uncategorized
 * Move Unsupported to between Interrupted and UnexpectedEof
 * Add some comments documenting where to add things

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
@rust-highfive
Copy link
Collaborator

r? @dtolnay

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 24, 2021
@@ -307,23 +314,24 @@ pub enum ErrorKind {
impl ErrorKind {
pub(crate) fn as_str(&self) -> &'static str {
use ErrorKind::*;
// Strictly alphabetical, please. (Sadly rustfmt cannot do this yet.)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you think it's warranted to check this automatically, https://crates.io/crates/remain

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah thanks :-). That would be nice, indeed.

However, I don't think this is used in rust-lang/rust already. I'm not at all sure what the rules/culture/whatever is for dependencies. If it's just for this one instance, perhaps it's not worth it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would strongly prefer if no proc-macros are used by libstd or it's dependencies.

@dtolnay
Copy link
Member

dtolnay commented Aug 24, 2021

Thanks!
@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 24, 2021

📌 Commit 7b5c0ec has been approved by dtolnay

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 24, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 25, 2021
…eulArtichaut

Rollup of 16 pull requests

Successful merges:

 - rust-lang#87944 (add Cell::as_array_of_cells, similar to Cell::as_slice_of_cells)
 - rust-lang#88156 (Adjust / fix documentation of `Arc::make_mut`)
 - rust-lang#88157 (bootstrap.py: recognize riscv64 when auto-detect)
 - rust-lang#88196 (Refactor `named_asm_labels` to a HIR lint)
 - rust-lang#88218 (Remove `Session.trait_methods_not_found`)
 - rust-lang#88223 (Remove the `TryV2` alias)
 - rust-lang#88226 (Fix typo “a Rc” → “an Rc” (and a few more))
 - rust-lang#88267 (2229: Update signature for truncate function)
 - rust-lang#88273 (Fix references to `ControlFlow` in docs)
 - rust-lang#88277 (Update books)
 - rust-lang#88291 (Add SAFETY comments to core::slice::sort::partition_in_blocks)
 - rust-lang#88293 (Fix grammar in alloc test)
 - rust-lang#88298 (Errorkind reorder)
 - rust-lang#88299 (Stabilise BufWriter::into_parts)
 - rust-lang#88314 (Add type of a let tait test)
 - rust-lang#88325 (Add mutable-noalias to the release notes for 1.54)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 82ecb0f into rust-lang:master Aug 25, 2021
@rustbot rustbot added this to the 1.56.0 milestone Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants