Simplify wildcard_enum_match_arm test

This commit is contained in:
flip1995 2021-07-01 11:47:56 +02:00
parent 38569c03eb
commit 0ffba7a684
No known key found for this signature in database
GPG key ID: 1CA0DF2AF59D68A5
4 changed files with 3 additions and 56 deletions

View file

@ -1,25 +1,8 @@
// Stripped down version of the ErrorKind enum of std
#[non_exhaustive]
pub enum ErrorKind {
NotFound,
PermissionDenied,
ConnectionRefused,
ConnectionReset,
ConnectionAborted,
NotConnected,
AddrInUse,
AddrNotAvailable,
BrokenPipe,
AlreadyExists,
WouldBlock,
InvalidInput,
InvalidData,
TimedOut,
WriteZero,
Interrupted,
Other,
UnexpectedEof,
Unsupported,
OutOfMemory,
#[doc(hidden)]
Uncategorized,
}

View file

@ -80,29 +80,11 @@ fn main() {
let error_kind = ErrorKind::NotFound;
match error_kind {
ErrorKind::NotFound => {},
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 | _ => {},
ErrorKind::PermissionDenied | _ => {},
}
match error_kind {
ErrorKind::NotFound => {},
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 => {},
_ => {},
}
}

View file

@ -85,24 +85,6 @@ fn main() {
match error_kind {
ErrorKind::NotFound => {},
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 => {},
_ => {},
}
}

View file

@ -32,7 +32,7 @@ error: wildcard matches known variants and will also match future added variants
--> $DIR/wildcard_enum_match_arm.rs:83:9
|
LL | _ => {},
| ^ 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 | _`
| ^ help: try this: `ErrorKind::PermissionDenied | _`
error: aborting due to 5 previous errors