Skip to content

Commit 541c8d8

Browse files
committed
Add ErrorKind::OutOfMemory
1 parent 6d4e3c1 commit 541c8d8

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

library/std/src/io/error.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ pub enum ErrorKind {
186186
/// This means that the operation can never succeed.
187187
#[stable(feature = "unsupported_error", since = "1.53.0")]
188188
Unsupported,
189+
190+
/// An operation could not be completed, because it failed
191+
/// to allocate enough memory.
192+
#[stable(feature = "out_of_memory_error", since = "1.53.0")]
193+
OutOfMemory,
189194
}
190195

191196
impl ErrorKind {
@@ -210,6 +215,7 @@ impl ErrorKind {
210215
ErrorKind::Other => "other os error",
211216
ErrorKind::UnexpectedEof => "unexpected end of file",
212217
ErrorKind::Unsupported => "unsupported",
218+
ErrorKind::OutOfMemory => "out of memory",
213219
}
214220
}
215221
}

src/tools/clippy/tests/ui/wildcard_enum_match_arm.fixed

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn main() {
7777
let error_kind = ErrorKind::NotFound;
7878
match error_kind {
7979
ErrorKind::NotFound => {},
80-
ErrorKind::PermissionDenied | ErrorKind::ConnectionRefused | ErrorKind::ConnectionReset | ErrorKind::ConnectionAborted | ErrorKind::NotConnected | ErrorKind::AddrInUse | ErrorKind::AddrNotAvailable | ErrorKind::BrokenPipe | ErrorKind::AlreadyExists | ErrorKind::WouldBlock | ErrorKind::InvalidInput | ErrorKind::InvalidData | ErrorKind::TimedOut | ErrorKind::WriteZero | ErrorKind::Interrupted | ErrorKind::Other | ErrorKind::UnexpectedEof | ErrorKind::Unsupported | _ => {},
80+
ErrorKind::PermissionDenied | ErrorKind::ConnectionRefused | ErrorKind::ConnectionReset | ErrorKind::ConnectionAborted | ErrorKind::NotConnected | ErrorKind::AddrInUse | ErrorKind::AddrNotAvailable | ErrorKind::BrokenPipe | ErrorKind::AlreadyExists | ErrorKind::WouldBlock | ErrorKind::InvalidInput | ErrorKind::InvalidData | ErrorKind::TimedOut | ErrorKind::WriteZero | ErrorKind::Interrupted | ErrorKind::Other | ErrorKind::UnexpectedEof | ErrorKind::Unsupported | ErrorKind::OutOfMemory | _ => {},
8181
}
8282
match error_kind {
8383
ErrorKind::NotFound => {},
@@ -99,6 +99,7 @@ fn main() {
9999
ErrorKind::Other => {},
100100
ErrorKind::UnexpectedEof => {},
101101
ErrorKind::Unsupported => {},
102+
ErrorKind::OutOfMemory => {},
102103
_ => {},
103104
}
104105
}

src/tools/clippy/tests/ui/wildcard_enum_match_arm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ fn main() {
9999
ErrorKind::Other => {},
100100
ErrorKind::UnexpectedEof => {},
101101
ErrorKind::Unsupported => {},
102+
ErrorKind::OutOfMemory => {},
102103
_ => {},
103104
}
104105
}

src/tools/clippy/tests/ui/wildcard_enum_match_arm.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ error: wildcard matches known variants and will also match future added variants
3232
--> $DIR/wildcard_enum_match_arm.rs:80:9
3333
|
3434
LL | _ => {},
35-
| ^ help: try this: `ErrorKind::PermissionDenied | ErrorKind::ConnectionRefused | ErrorKind::ConnectionReset | ErrorKind::ConnectionAborted | ErrorKind::NotConnected | ErrorKind::AddrInUse | ErrorKind::AddrNotAvailable | ErrorKind::BrokenPipe | ErrorKind::AlreadyExists | ErrorKind::WouldBlock | ErrorKind::InvalidInput | ErrorKind::InvalidData | ErrorKind::TimedOut | ErrorKind::WriteZero | ErrorKind::Interrupted | ErrorKind::Other | ErrorKind::UnexpectedEof | ErrorKind::Unsupported | _`
35+
| ^ help: try this: `ErrorKind::PermissionDenied | ErrorKind::ConnectionRefused | ErrorKind::ConnectionReset | ErrorKind::ConnectionAborted | ErrorKind::NotConnected | ErrorKind::AddrInUse | ErrorKind::AddrNotAvailable | ErrorKind::BrokenPipe | ErrorKind::AlreadyExists | ErrorKind::WouldBlock | ErrorKind::InvalidInput | ErrorKind::InvalidData | ErrorKind::TimedOut | ErrorKind::WriteZero | ErrorKind::Interrupted | ErrorKind::Other | ErrorKind::UnexpectedEof | ErrorKind::Unsupported | ErrorKind::OutOfMemory | _`
3636

3737
error: aborting due to 5 previous errors
3838

0 commit comments

Comments
 (0)