Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Mar 20, 2024
1 parent 3c17caf commit 80cc500
Show file tree
Hide file tree
Showing 63 changed files with 721 additions and 811 deletions.
2 changes: 1 addition & 1 deletion tests/mir-opt/uninhabited_enum_branching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct Plop {
fn simple() {
// CHECK-LABEL: fn simple(
// CHECK: [[discr:_.*]] = discriminant(
// CHECK: switchInt(move [[discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: bb2, otherwise: [[unreachable]]];
// CHECK: switchInt(move [[discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: bb1, otherwise: [[unreachable]]];
// CHECK: [[unreachable]]: {
// CHECK-NEXT: unreachable;
match Test1::C {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,40 @@
StorageLive(_2);
_2 = Test1::C;
_3 = discriminant(_2);
- switchInt(move _3) -> [0: bb3, 1: bb4, 2: bb2, otherwise: bb1];
+ switchInt(move _3) -> [0: bb1, 1: bb1, 2: bb2, otherwise: bb1];
- switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1];
+ switchInt(move _3) -> [0: bb5, 1: bb5, 2: bb1, otherwise: bb5];
}

bb1: {
unreachable;
}

bb2: {
StorageLive(_5);
_5 = const "C";
_1 = &(*_5);
StorageDead(_5);
goto -> bb5;
goto -> bb4;
}

bb3: {
bb2: {
_1 = const "A(Empty)";
goto -> bb5;
goto -> bb4;
}

bb4: {
bb3: {
StorageLive(_4);
_4 = const "B(Empty)";
_1 = &(*_4);
StorageDead(_4);
goto -> bb5;
goto -> bb4;
}

bb5: {
bb4: {
StorageDead(_2);
StorageDead(_1);
_0 = const ();
return;
+ }
+
+ bb5: {
+ unreachable;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
let mut _2: isize;
let _3: Empty;
let mut _4: !;
+ let mut _5: bool;
scope 1 {
debug _x => _3;
}
Expand All @@ -18,25 +17,6 @@
}

bb1: {
_2 = discriminant(_1);
- switchInt(move _2) -> [0: bb4, 1: bb3, otherwise: bb2];
+ _5 = Eq(_2, const 0_isize);
+ assume(move _5);
+ goto -> bb4;
}

bb2: {
unreachable;
}

bb3: {
- StorageLive(_3);
- _3 = move ((_1 as Some).0: Empty);
- StorageLive(_4);
unreachable;
}

bb4: {
_0 = const ();
StorageDead(_1);
return;
Expand Down
13 changes: 3 additions & 10 deletions tests/mir-opt/unreachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn if_let() {
_y = 42;
}

match _x { }
match _x {}
}
}

Expand All @@ -45,18 +45,11 @@ fn as_match() {
// CHECK: bb0: {
// CHECK: {{_.*}} = empty()
// CHECK: bb1: {
// CHECK: [[eq:_.*]] = Eq({{.*}}, const 0_isize);
// CHECK-NEXT: assume(move [[eq]]);
// CHECK-NEXT: goto -> bb4;
// CHECK: bb2: {
// CHECK-NEXT: unreachable;
// CHECK: bb3: {
// CHECK-NEXT: unreachable;
// CHECK: bb4: {
// CHECK-NEXT: _0 = const ();
// CHECK: return;
match empty() {
None => {}
Some(_x) => match _x {}
Some(_x) => match _x {},
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Test precise capture of a multi-variant enum (when remaining variants are
// visibly uninhabited).
//@ revisions: min_exhaustive_patterns exhaustive_patterns
//@ revisions: normal exhaustive_patterns
//@ edition:2021
//@ run-pass
#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))]
#![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))]
#![feature(never_type)]

pub fn main() {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/codemap_tests/huge_multispan_highlight.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//@ run-pass

#![allow(unreachable_patterns)]
#![allow(dead_code)]

enum Empty { }
enum Empty {}
enum Test1 {
A(u8),
B(Empty),
Expand Down
1 change: 1 addition & 0 deletions tests/ui/enum-discriminant/issue-61696.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ run-pass
#![allow(unreachable_patterns)]

pub enum Infallible {}

Expand Down
1 change: 1 addition & 0 deletions tests/ui/enum-discriminant/niche.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ run-pass
#![allow(unreachable_patterns)]

//! Make sure that we read and write enum discriminants correctly for corner cases caused
//! by layout optimizations.
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/feature-gates/feature-gate-exhaustive-patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ fn foo() -> Result<u32, !> {
}

fn main() {
let Ok(_x) = foo(); //~ ERROR refutable pattern in local binding
let Ok(_x) = &foo(); //~ ERROR refutable pattern in local binding
}
10 changes: 5 additions & 5 deletions tests/ui/feature-gates/feature-gate-exhaustive-patterns.stderr
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
error[E0005]: refutable pattern in local binding
--> $DIR/feature-gate-exhaustive-patterns.rs:8:9
|
LL | let Ok(_x) = foo();
| ^^^^^^ pattern `Err(_)` not covered
LL | let Ok(_x) = &foo();
| ^^^^^^ pattern `&Err(_)` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: the matched value is of type `Result<u32, !>`
= note: the matched value is of type `&Result<u32, !>`
help: you might want to use `let else` to handle the variant that isn't matched
|
LL | let Ok(_x) = foo() else { todo!() };
| ++++++++++++++++
LL | let Ok(_x) = &foo() else { todo!() };
| ++++++++++++++++

error: aborting due to 1 previous error

Expand Down
5 changes: 2 additions & 3 deletions tests/ui/never_type/never-result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

#![allow(unused_variables)]
#![allow(unreachable_code)]

#![allow(unreachable_patterns)]
// Test that we can extract a ! through pattern matching then use it as several different types.

#![feature(never_type)]

fn main() {
Expand All @@ -16,6 +15,6 @@ fn main() {
let w: i32 = y;
let e: String = y;
y
},
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: type `&!` is non-empty
--> $DIR/always-inhabited-union-ref.rs:25:11
--> $DIR/always-inhabited-union-ref.rs:24:11
|
LL | match uninhab_ref() {
| ^^^^^^^^^^^^^
Expand All @@ -14,13 +14,13 @@ LL + }
|

error[E0004]: non-exhaustive patterns: type `Foo` is non-empty
--> $DIR/always-inhabited-union-ref.rs:29:11
--> $DIR/always-inhabited-union-ref.rs:28:11
|
LL | match uninhab_union() {
| ^^^^^^^^^^^^^^^
|
note: `Foo` defined here
--> $DIR/always-inhabited-union-ref.rs:12:11
--> $DIR/always-inhabited-union-ref.rs:11:11
|
LL | pub union Foo {
| ^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: type `&!` is non-empty
--> $DIR/always-inhabited-union-ref.rs:25:11
--> $DIR/always-inhabited-union-ref.rs:24:11
|
LL | match uninhab_ref() {
| ^^^^^^^^^^^^^
Expand All @@ -14,13 +14,13 @@ LL + }
|

error[E0004]: non-exhaustive patterns: type `Foo` is non-empty
--> $DIR/always-inhabited-union-ref.rs:29:11
--> $DIR/always-inhabited-union-ref.rs:28:11
|
LL | match uninhab_union() {
| ^^^^^^^^^^^^^^^
|
note: `Foo` defined here
--> $DIR/always-inhabited-union-ref.rs:12:11
--> $DIR/always-inhabited-union-ref.rs:11:11
|
LL | pub union Foo {
| ^^^
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/pattern/usefulness/always-inhabited-union-ref.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
//@ revisions: min_exhaustive_patterns exhaustive_patterns
//@ revisions: normal exhaustive_patterns

// The precise semantics of inhabitedness with respect to unions and references is currently
// undecided. This test file currently checks a conservative choice.

#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))]
#![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))]
#![feature(never_type)]
#![allow(dead_code)]
#![allow(unreachable_code)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ LL | _ if false => {}
error[E0005]: refutable pattern in local binding
--> $DIR/empty-match-check-notes.rs:35:9
|
LL | let None = x;
LL | let None = *x;
| ^^^^ pattern `Some(_)` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
Expand All @@ -40,8 +40,8 @@ LL | let None = x;
= note: the matched value is of type `Option<SecretlyUninhabitedForeignStruct>`
help: you might want to use `if let` to ignore the variant that isn't matched
|
LL | if let None = x { todo!() };
| ++ +++++++++++
LL | if let None = *x { todo!() };
| ++ +++++++++++

error[E0004]: non-exhaustive patterns: `0_u8..=u8::MAX` not covered
--> $DIR/empty-match-check-notes.rs:45:11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ LL | _ if false => {}
error[E0005]: refutable pattern in local binding
--> $DIR/empty-match-check-notes.rs:35:9
|
LL | let None = x;
LL | let None = *x;
| ^^^^ pattern `Some(_)` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: pattern `Some(_)` is currently uninhabited, but this variant contains private fields which may become inhabited in the future
= note: the matched value is of type `Option<SecretlyUninhabitedForeignStruct>`
help: you might want to use `if let` to ignore the variant that isn't matched
|
LL | if let None = x { todo!() };
| ++ +++++++++++
LL | if let None = *x { todo!() };
| ++ +++++++++++

error[E0004]: non-exhaustive patterns: `0_u8..=u8::MAX` not covered
--> $DIR/empty-match-check-notes.rs:45:11
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/pattern/usefulness/empty-match-check-notes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ fn empty_foreign_enum(x: empty::EmptyForeignEnum) {
}
}

fn empty_foreign_enum_private(x: Option<empty::SecretlyUninhabitedForeignStruct>) {
let None = x;
fn empty_foreign_enum_private(x: &Option<empty::SecretlyUninhabitedForeignStruct>) {
let None = *x;
//~^ ERROR refutable pattern in local binding
//~| NOTE `let` bindings require an "irrefutable pattern"
//~| NOTE for more information, visit
//~| NOTE the matched value is of type
//~| NOTE pattern `Some(_)` not covered
//[exhaustive_patterns]~| NOTE currently uninhabited, but this variant contains private fields
//~| NOTE currently uninhabited, but this variant contains private fields
}

fn main() {
Expand Down
Loading

0 comments on commit 80cc500

Please sign in to comment.