forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#100305 - TaKO8Ki:suggest-adding-appropriate…
…-missing-pattern-excluding-comments, r=compiler-errors Suggest adding an appropriate missing pattern excluding comments fixes rust-lang#100272
- Loading branch information
Showing
4 changed files
with
57 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/test/ui/pattern/suggest-adding-appropriate-missing-pattern-excluding-comments.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// run-rustfix | ||
|
||
fn main() { | ||
match Some(1) { //~ ERROR non-exhaustive patterns: `None` not covered | ||
Some(1) => {} | ||
// hello | ||
Some(_) => {} | ||
None => todo!() | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/test/ui/pattern/suggest-adding-appropriate-missing-pattern-excluding-comments.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// run-rustfix | ||
|
||
fn main() { | ||
match Some(1) { //~ ERROR non-exhaustive patterns: `None` not covered | ||
Some(1) => {} | ||
// hello | ||
Some(_) => {} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/test/ui/pattern/suggest-adding-appropriate-missing-pattern-excluding-comments.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
error[E0004]: non-exhaustive patterns: `None` not covered | ||
--> $DIR/suggest-adding-appropriate-missing-pattern-excluding-comments.rs:4:11 | ||
| | ||
LL | match Some(1) { | ||
| ^^^^^^^ pattern `None` not covered | ||
| | ||
note: `Option<i32>` defined here | ||
--> $SRC_DIR/core/src/option.rs:LL:COL | ||
| | ||
LL | pub enum Option<T> { | ||
| ------------------ | ||
... | ||
LL | None, | ||
| ^^^^ not covered | ||
= note: the matched value is of type `Option<i32>` | ||
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | ||
| | ||
LL ~ Some(_) => {} | ||
LL + None => todo!() | ||
| | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0004`. |