Skip to content

Commit 4c0203e

Browse files
committed
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 Signed-off-by: Ian Jackson <[email protected]>
1 parent 54df693 commit 4c0203e

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

Diff for: library/std/src/io/error.rs

+24-17
Original file line numberDiff line numberDiff line change
@@ -261,18 +261,14 @@ pub enum ErrorKind {
261261
#[stable(feature = "rust1", since = "1.0.0")]
262262
Interrupted,
263263

264-
/// A custom error that does not fall under any other I/O error kind.
265-
///
266-
/// This can be used to construct your own [`Error`]s that do not match any
267-
/// [`ErrorKind`].
268-
///
269-
/// This [`ErrorKind`] is not used by the standard library.
264+
/// This operation is unsupported on this platform.
270265
///
271-
/// Errors from the standard library that do not fall under any of the I/O
272-
/// error kinds cannot be `match`ed on, and will only match a wildcard (`_`) pattern.
273-
/// New [`ErrorKind`]s might be added in the future for some of those.
274-
#[stable(feature = "rust1", since = "1.0.0")]
275-
Other,
266+
/// This means that the operation can never succeed.
267+
#[stable(feature = "unsupported_error", since = "1.53.0")]
268+
Unsupported,
269+
270+
// ErrorKinds which are primarily categorisations for OS error
271+
// codes should be added above.
276272

277273
/// An error returned when an operation could not be completed because an
278274
/// "end of file" was reached prematurely.
@@ -283,17 +279,28 @@ pub enum ErrorKind {
283279
#[stable(feature = "read_exact", since = "1.6.0")]
284280
UnexpectedEof,
285281

286-
/// This operation is unsupported on this platform.
287-
///
288-
/// This means that the operation can never succeed.
289-
#[stable(feature = "unsupported_error", since = "1.53.0")]
290-
Unsupported,
291-
292282
/// An operation could not be completed, because it failed
293283
/// to allocate enough memory.
294284
#[stable(feature = "out_of_memory_error", since = "1.54.0")]
295285
OutOfMemory,
296286

287+
// "Unusual" error kinds which do not correspond simply to (sets
288+
// of) OS error codes, should be added just above this comment.
289+
// `Other` and `Uncategorised` should remain at the end:
290+
291+
/// A custom error that does not fall under any other I/O error kind.
292+
///
293+
/// This can be used to construct your own [`Error`]s that do not match any
294+
/// [`ErrorKind`].
295+
///
296+
/// This [`ErrorKind`] is not used by the standard library.
297+
///
298+
/// Errors from the standard library that do not fall under any of the I/O
299+
/// error kinds cannot be `match`ed on, and will only match a wildcard (`_`) pattern.
300+
/// New [`ErrorKind`]s might be added in the future for some of those.
301+
#[stable(feature = "rust1", since = "1.0.0")]
302+
Other,
303+
297304
/// Any I/O error from the standard library that's not part of this list.
298305
///
299306
/// Errors that are `Uncategorized` now may move to a different or a new

0 commit comments

Comments
 (0)