Skip to content

Commit 4733b1b

Browse files
committed
Test min_exhaustive_patterns in more cases
1 parent 30793ca commit 4733b1b

16 files changed

+188
-23
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: the feature `min_exhaustive_patterns` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/multivariant.rs:7:46
3+
|
4+
LL | #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #119612 <https://github.com/rust-lang/rust/issues/119612> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
warning: 1 warning emitted
11+

tests/ui/closures/2229_closure_analysis/run_pass/multivariant.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// Test precise capture of a multi-variant enum (when remaining variants are
22
// visibly uninhabited).
3+
// revisions: min_exhaustive_patterns exhaustive_patterns
34
// edition:2021
45
// run-pass
5-
#![feature(exhaustive_patterns)]
6+
#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))]
7+
#![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))]
8+
//[min_exhaustive_patterns]~^ WARN the feature `min_exhaustive_patterns` is incomplete
69
#![feature(never_type)]
710

811
pub fn main() {

tests/ui/pattern/usefulness/always-inhabited-union-ref.stderr renamed to tests/ui/pattern/usefulness/always-inhabited-union-ref.exhaustive_patterns.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0004]: non-exhaustive patterns: type `&!` is non-empty
2-
--> $DIR/always-inhabited-union-ref.rs:23:11
2+
--> $DIR/always-inhabited-union-ref.rs:26:11
33
|
44
LL | match uninhab_ref() {
55
| ^^^^^^^^^^^^^
@@ -14,13 +14,13 @@ LL + }
1414
|
1515

1616
error[E0004]: non-exhaustive patterns: type `Foo` is non-empty
17-
--> $DIR/always-inhabited-union-ref.rs:27:11
17+
--> $DIR/always-inhabited-union-ref.rs:30:11
1818
|
1919
LL | match uninhab_union() {
2020
| ^^^^^^^^^^^^^^^
2121
|
2222
note: `Foo` defined here
23-
--> $DIR/always-inhabited-union-ref.rs:10:11
23+
--> $DIR/always-inhabited-union-ref.rs:13:11
2424
|
2525
LL | pub union Foo {
2626
| ^^^
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
warning: the feature `min_exhaustive_patterns` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/always-inhabited-union-ref.rs:7:46
3+
|
4+
LL | #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #119612 <https://github.com/rust-lang/rust/issues/119612> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error[E0004]: non-exhaustive patterns: type `&!` is non-empty
11+
--> $DIR/always-inhabited-union-ref.rs:26:11
12+
|
13+
LL | match uninhab_ref() {
14+
| ^^^^^^^^^^^^^
15+
|
16+
= note: the matched value is of type `&!`
17+
= note: references are always considered inhabited
18+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
19+
|
20+
LL ~ match uninhab_ref() {
21+
LL + _ => todo!(),
22+
LL + }
23+
|
24+
25+
error[E0004]: non-exhaustive patterns: type `Foo` is non-empty
26+
--> $DIR/always-inhabited-union-ref.rs:30:11
27+
|
28+
LL | match uninhab_union() {
29+
| ^^^^^^^^^^^^^^^
30+
|
31+
note: `Foo` defined here
32+
--> $DIR/always-inhabited-union-ref.rs:13:11
33+
|
34+
LL | pub union Foo {
35+
| ^^^
36+
= note: the matched value is of type `Foo`
37+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
38+
|
39+
LL ~ match uninhab_union() {
40+
LL + _ => todo!(),
41+
LL + }
42+
|
43+
44+
error: aborting due to 2 previous errors; 1 warning emitted
45+
46+
For more information about this error, try `rustc --explain E0004`.

tests/ui/pattern/usefulness/always-inhabited-union-ref.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
// revisions: min_exhaustive_patterns exhaustive_patterns
2+
13
// The precise semantics of inhabitedness with respect to unions and references is currently
24
// undecided. This test file currently checks a conservative choice.
35

4-
#![feature(exhaustive_patterns)]
6+
#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))]
7+
#![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))]
8+
//[min_exhaustive_patterns]~^ WARN the feature `min_exhaustive_patterns` is incomplete
59
#![feature(never_type)]
6-
710
#![allow(dead_code)]
811
#![allow(unreachable_code)]
912

tests/ui/pattern/usefulness/match-privately-empty.stderr renamed to tests/ui/pattern/usefulness/match-privately-empty.exhaustive_patterns.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0004]: non-exhaustive patterns: `Some(Private { misc: true, .. })` not covered
2-
--> $DIR/match-privately-empty.rs:13:11
2+
--> $DIR/match-privately-empty.rs:16:11
33
|
44
LL | match private::DATA {
55
| ^^^^^^^^^^^^^ pattern `Some(Private { misc: true, .. })` not covered
@@ -12,7 +12,7 @@ note: `Option<Private>` defined here
1212
= note: the matched value is of type `Option<Private>`
1313
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
1414
|
15-
LL ~ }) => {},
15+
LL ~ Some(private::Private { misc: false, .. }) => {},
1616
LL + Some(Private { misc: true, .. }) => todo!()
1717
|
1818

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
warning: the feature `min_exhaustive_patterns` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/match-privately-empty.rs:3:46
3+
|
4+
LL | #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #119612 <https://github.com/rust-lang/rust/issues/119612> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error[E0004]: non-exhaustive patterns: `Some(Private { misc: true, .. })` not covered
11+
--> $DIR/match-privately-empty.rs:16:11
12+
|
13+
LL | match private::DATA {
14+
| ^^^^^^^^^^^^^ pattern `Some(Private { misc: true, .. })` not covered
15+
|
16+
note: `Option<Private>` defined here
17+
--> $SRC_DIR/core/src/option.rs:LL:COL
18+
::: $SRC_DIR/core/src/option.rs:LL:COL
19+
|
20+
= note: not covered
21+
= note: the matched value is of type `Option<Private>`
22+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
23+
|
24+
LL ~ Some(private::Private { misc: false, .. }) => {},
25+
LL + Some(Private { misc: true, .. }) => todo!()
26+
|
27+
28+
error: aborting due to 1 previous error; 1 warning emitted
29+
30+
For more information about this error, try `rustc --explain E0004`.
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
// revisions: min_exhaustive_patterns exhaustive_patterns
2+
#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))]
3+
#![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))]
4+
//[min_exhaustive_patterns]~^ WARN the feature `min_exhaustive_patterns` is incomplete
15
#![feature(never_type)]
2-
#![feature(exhaustive_patterns)]
36

47
mod private {
58
pub struct Private {
@@ -11,11 +14,8 @@ mod private {
1114

1215
fn main() {
1316
match private::DATA {
14-
//~^ ERROR non-exhaustive patterns: `Some(Private { misc: true, .. })` not covered
17+
//~^ ERROR non-exhaustive patterns: `Some(Private { misc: true, .. })` not covered
1518
None => {}
16-
Some(private::Private {
17-
misc: false,
18-
..
19-
}) => {}
19+
Some(private::Private { misc: false, .. }) => {}
2020
}
2121
}

tests/ui/pattern/usefulness/slice_of_empty.stderr renamed to tests/ui/pattern/usefulness/slice_of_empty.exhaustive_patterns.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0004]: non-exhaustive patterns: `&[]` not covered
2-
--> $DIR/slice_of_empty.rs:18:11
2+
--> $DIR/slice_of_empty.rs:22:11
33
|
44
LL | match nevers {
55
| ^^^^^^ pattern `&[]` not covered
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
warning: the feature `min_exhaustive_patterns` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/slice_of_empty.rs:3:46
3+
|
4+
LL | #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #119612 <https://github.com/rust-lang/rust/issues/119612> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered
11+
--> $DIR/slice_of_empty.rs:11:11
12+
|
13+
LL | match nevers {
14+
| ^^^^^^ pattern `&[_, ..]` not covered
15+
|
16+
= note: the matched value is of type `&[!]`
17+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
18+
|
19+
LL ~ &[] => (),
20+
LL ~ &[_, ..] => todo!(),
21+
|
22+
23+
error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered
24+
--> $DIR/slice_of_empty.rs:22:11
25+
|
26+
LL | match nevers {
27+
| ^^^^^^ patterns `&[]` and `&[_, _, ..]` not covered
28+
|
29+
= note: the matched value is of type `&[!]`
30+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
31+
|
32+
LL ~ &[_] => (),
33+
LL ~ &[] | &[_, _, ..] => todo!(),
34+
|
35+
36+
error: aborting due to 2 previous errors; 1 warning emitted
37+
38+
For more information about this error, try `rustc --explain E0004`.

0 commit comments

Comments
 (0)