Skip to content

Commit 3e59563

Browse files
committed
Don't use exact definition of std's ErrorKind in test.
Every time we add something to this enum in std, this test breaks.
1 parent 8d427b6 commit 3e59563

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#[non_exhaustive]
2+
pub enum ErrorKind {
3+
NotFound,
4+
PermissionDenied,
5+
ConnectionRefused,
6+
ConnectionReset,
7+
ConnectionAborted,
8+
NotConnected,
9+
AddrInUse,
10+
AddrNotAvailable,
11+
BrokenPipe,
12+
AlreadyExists,
13+
WouldBlock,
14+
InvalidInput,
15+
InvalidData,
16+
TimedOut,
17+
WriteZero,
18+
Interrupted,
19+
Other,
20+
UnexpectedEof,
21+
Unsupported,
22+
OutOfMemory,
23+
}

tests/ui/wildcard_enum_match_arm.fixed

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// run-rustfix
2+
// aux-build:non-exhaustive-enum.rs
23

34
#![deny(clippy::wildcard_enum_match_arm)]
45
#![allow(
@@ -11,7 +12,9 @@
1112
clippy::diverging_sub_expression
1213
)]
1314

14-
use std::io::ErrorKind;
15+
extern crate non_exhaustive_enum;
16+
17+
use non_exhaustive_enum::ErrorKind;
1518

1619
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
1720
enum Color {

tests/ui/wildcard_enum_match_arm.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// run-rustfix
2+
// aux-build:non-exhaustive-enum.rs
23

34
#![deny(clippy::wildcard_enum_match_arm)]
45
#![allow(
@@ -11,7 +12,9 @@
1112
clippy::diverging_sub_expression
1213
)]
1314

14-
use std::io::ErrorKind;
15+
extern crate non_exhaustive_enum;
16+
17+
use non_exhaustive_enum::ErrorKind;
1518

1619
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
1720
enum Color {

tests/ui/wildcard_enum_match_arm.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
error: wildcard match will also match any future added variants
2-
--> $DIR/wildcard_enum_match_arm.rs:39:9
2+
--> $DIR/wildcard_enum_match_arm.rs:42:9
33
|
44
LL | _ => eprintln!("Not red"),
55
| ^ help: try this: `Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan`
66
|
77
note: the lint level is defined here
8-
--> $DIR/wildcard_enum_match_arm.rs:3:9
8+
--> $DIR/wildcard_enum_match_arm.rs:4:9
99
|
1010
LL | #![deny(clippy::wildcard_enum_match_arm)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: wildcard match will also match any future added variants
14-
--> $DIR/wildcard_enum_match_arm.rs:43:9
14+
--> $DIR/wildcard_enum_match_arm.rs:46:9
1515
|
1616
LL | _not_red => eprintln!("Not red"),
1717
| ^^^^^^^^ help: try this: `_not_red @ Color::Green | _not_red @ Color::Blue | _not_red @ Color::Rgb(..) | _not_red @ Color::Cyan`
1818

1919
error: wildcard match will also match any future added variants
20-
--> $DIR/wildcard_enum_match_arm.rs:47:9
20+
--> $DIR/wildcard_enum_match_arm.rs:50:9
2121
|
2222
LL | not_red => format!("{:?}", not_red),
2323
| ^^^^^^^ help: try this: `not_red @ Color::Green | not_red @ Color::Blue | not_red @ Color::Rgb(..) | not_red @ Color::Cyan`
2424

2525
error: wildcard match will also match any future added variants
26-
--> $DIR/wildcard_enum_match_arm.rs:63:9
26+
--> $DIR/wildcard_enum_match_arm.rs:66:9
2727
|
2828
LL | _ => "No red",
2929
| ^ help: try this: `Color::Red | Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan`
3030

3131
error: wildcard matches known variants and will also match future added variants
32-
--> $DIR/wildcard_enum_match_arm.rs:80:9
32+
--> $DIR/wildcard_enum_match_arm.rs:83:9
3333
|
3434
LL | _ => {},
3535
| ^ 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 | _`

0 commit comments

Comments
 (0)