-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filter unstable and doc hidden variants in usefulness checking
Add test cases for unstable variants Add test cases for doc hidden variants Move is_doc_hidden to method on TyCtxt Add unstable variants test to reachable-patterns ui test Rename reachable-patterns -> omitted-patterns
- Loading branch information
Showing
16 changed files
with
428 additions
and
92 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
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
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
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,6 @@ | ||
pub enum Foo { | ||
A, | ||
B, | ||
#[doc(hidden)] | ||
C, | ||
} |
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,12 @@ | ||
#![feature(staged_api)] | ||
#![stable(feature = "stable_test_feature", since = "1.0.0")] | ||
|
||
#[stable(feature = "stable_test_feature", since = "1.0.0")] | ||
pub enum Foo { | ||
#[stable(feature = "stable_test_feature", since = "1.0.0")] | ||
Stable, | ||
#[stable(feature = "stable_test_feature", since = "1.0.0")] | ||
Stable2, | ||
#[unstable(feature = "unstable_test_feature", issue = "none")] | ||
Unstable, | ||
} |
30 changes: 30 additions & 0 deletions
30
src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.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,30 @@ | ||
// aux-build:hidden.rs | ||
|
||
extern crate hidden; | ||
|
||
use hidden::Foo; | ||
|
||
fn main() { | ||
match Foo::A { | ||
Foo::A => {} | ||
Foo::B => {} | ||
} | ||
//~^^^^ non-exhaustive patterns: `_` not covered | ||
|
||
match Foo::A { | ||
Foo::A => {} | ||
Foo::C => {} | ||
} | ||
//~^^^^ non-exhaustive patterns: `B` not covered | ||
|
||
match Foo::A { | ||
Foo::A => {} | ||
} | ||
//~^^^ non-exhaustive patterns: `B` and `_` not covered | ||
|
||
match None { | ||
None => {} | ||
Some(Foo::A) => {} | ||
} | ||
//~^^^^ non-exhaustive patterns: `Some(B)` and `Some(_)` not covered | ||
} |
54 changes: 54 additions & 0 deletions
54
src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.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,54 @@ | ||
error[E0004]: non-exhaustive patterns: `_` not covered | ||
--> $DIR/doc-hidden-non-exhaustive.rs:8:11 | ||
| | ||
LL | match Foo::A { | ||
| ^^^^^^ pattern `_` not covered | ||
| | ||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms | ||
= note: the matched value is of type `Foo` | ||
|
||
error[E0004]: non-exhaustive patterns: `B` not covered | ||
--> $DIR/doc-hidden-non-exhaustive.rs:14:11 | ||
| | ||
LL | match Foo::A { | ||
| ^^^^^^ pattern `B` not covered | ||
| | ||
::: $DIR/auxiliary/hidden.rs:3:5 | ||
| | ||
LL | B, | ||
| - not covered | ||
| | ||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms | ||
= note: the matched value is of type `Foo` | ||
|
||
error[E0004]: non-exhaustive patterns: `B` and `_` not covered | ||
--> $DIR/doc-hidden-non-exhaustive.rs:20:11 | ||
| | ||
LL | match Foo::A { | ||
| ^^^^^^ patterns `B` and `_` not covered | ||
| | ||
::: $DIR/auxiliary/hidden.rs:3:5 | ||
| | ||
LL | B, | ||
| - not covered | ||
| | ||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms | ||
= note: the matched value is of type `Foo` | ||
|
||
error[E0004]: non-exhaustive patterns: `Some(B)` and `Some(_)` not covered | ||
--> $DIR/doc-hidden-non-exhaustive.rs:25:11 | ||
| | ||
LL | match None { | ||
| ^^^^ patterns `Some(B)` and `Some(_)` not covered | ||
| | ||
::: $SRC_DIR/core/src/option.rs:LL:COL | ||
| | ||
LL | Some(#[stable(feature = "rust1", since = "1.0.0")] T), | ||
| ---- not covered | ||
| | ||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms | ||
= note: the matched value is of type `Option<Foo>` | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0004`. |
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,18 @@ | ||
// aux-build:unstable.rs | ||
|
||
extern crate unstable; | ||
|
||
use unstable::Foo; | ||
|
||
fn main() { | ||
match Foo::Stable { | ||
Foo::Stable => {} | ||
} | ||
//~^^^ non-exhaustive patterns: `Stable2` and `_` not covered | ||
|
||
match Foo::Stable { | ||
Foo::Stable => {} | ||
Foo::Stable2 => {} | ||
} | ||
//~^^^^ non-exhaustive patterns: `_` not covered | ||
} |
26 changes: 26 additions & 0 deletions
26
src/test/ui/pattern/usefulness/stable-gated-patterns.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,26 @@ | ||
error[E0004]: non-exhaustive patterns: `Stable2` and `_` not covered | ||
--> $DIR/stable-gated-patterns.rs:8:11 | ||
| | ||
LL | match Foo::Stable { | ||
| ^^^^^^^^^^^ patterns `Stable2` and `_` not covered | ||
| | ||
::: $DIR/auxiliary/unstable.rs:9:5 | ||
| | ||
LL | Stable2, | ||
| ------- not covered | ||
| | ||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms | ||
= note: the matched value is of type `Foo` | ||
|
||
error[E0004]: non-exhaustive patterns: `_` not covered | ||
--> $DIR/stable-gated-patterns.rs:13:11 | ||
| | ||
LL | match Foo::Stable { | ||
| ^^^^^^^^^^^ pattern `_` not covered | ||
| | ||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms | ||
= note: the matched value is of type `Foo` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0004`. |
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,22 @@ | ||
#![feature(unstable_test_feature)] | ||
|
||
// aux-build:unstable.rs | ||
|
||
extern crate unstable; | ||
|
||
use unstable::Foo; | ||
|
||
fn main() { | ||
match Foo::Stable { | ||
Foo::Stable => {} | ||
Foo::Stable2 => {} | ||
} | ||
//~^^^^ non-exhaustive patterns: `Unstable` not covered | ||
|
||
// Ok: all variants are explicitly matched | ||
match Foo::Stable { | ||
Foo::Stable => {} | ||
Foo::Stable2 => {} | ||
Foo::Unstable => {} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/test/ui/pattern/usefulness/unstable-gated-patterns.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,17 @@ | ||
error[E0004]: non-exhaustive patterns: `Unstable` not covered | ||
--> $DIR/unstable-gated-patterns.rs:10:11 | ||
| | ||
LL | match Foo::Stable { | ||
| ^^^^^^^^^^^ pattern `Unstable` not covered | ||
| | ||
::: $DIR/auxiliary/unstable.rs:11:5 | ||
| | ||
LL | Unstable, | ||
| -------- not covered | ||
| | ||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms | ||
= note: the matched value is of type `Foo` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0004`. |
Oops, something went wrong.