Skip to content

Commit a0c5087

Browse files
committed
single_match: Clarify the don't lint test case
1 parent a5a07e5 commit a0c5087

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

tests/ui/single_match.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ fn ranges() {
152152
}
153153
let x = (Some(E::V), Some(42));
154154

155-
// don't lint
155+
// Don't lint, because the `E` enum can be extended with additional fields later. Thus, the
156+
// proposed replacement to `if let Some(E::V)` may hide non-exhaustive warnings that appeared
157+
// because of `match` construction.
156158
match x {
157159
(Some(E::V), _) => {},
158160
(None, _) => {},
@@ -176,19 +178,19 @@ fn ranges() {
176178
(..) => {},
177179
}
178180

179-
// don't lint
181+
// Don't lint, see above.
180182
match (Some(E::V), Some(E::V), Some(E::V)) {
181183
(.., Some(E::V), _) => {},
182184
(.., None, _) => {},
183185
}
184186

185-
// don't lint
187+
// Don't lint, see above.
186188
match (Some(E::V), Some(E::V), Some(E::V)) {
187189
(Some(E::V), ..) => {},
188190
(None, ..) => {},
189191
}
190192

191-
// don't lint
193+
// Don't lint, see above.
192194
match (Some(E::V), Some(E::V), Some(E::V)) {
193195
(_, Some(E::V), ..) => {},
194196
(_, None, ..) => {},

tests/ui/single_match.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ LL | | };
120120
| |_____^ help: try this: `if let None = x { println!() }`
121121

122122
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
123-
--> $DIR/single_match.rs:162:5
123+
--> $DIR/single_match.rs:164:5
124124
|
125125
LL | / match x {
126126
LL | | (Some(_), _) => {},
@@ -129,7 +129,7 @@ LL | | }
129129
| |_____^ help: try this: `if let (Some(_), _) = x {}`
130130

131131
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
132-
--> $DIR/single_match.rs:168:5
132+
--> $DIR/single_match.rs:170:5
133133
|
134134
LL | / match x {
135135
LL | | (Some(E::V), _) => todo!(),
@@ -138,7 +138,7 @@ LL | | }
138138
| |_____^ help: try this: `if let (Some(E::V), _) = x { todo!() }`
139139

140140
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
141-
--> $DIR/single_match.rs:174:5
141+
--> $DIR/single_match.rs:176:5
142142
|
143143
LL | / match (Some(42), Some(E::V), Some(42)) {
144144
LL | | (.., Some(E::V), _) => {},

0 commit comments

Comments
 (0)