Skip to content

Commit 38f636e

Browse files
authored
Unrolled build for #148928
Rollup merge of #148928 - WaffleLapkin:always-test, r=jieyouxu Move & adjust some `!`-adjacent tests I'm trying to clean up tests relating to the never type...
2 parents 6d41834 + fd50a37 commit 38f636e

File tree

7 files changed

+33
-20
lines changed

7 files changed

+33
-20
lines changed

tests/mir-opt/uninhabited_enum.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// skip-filecheck
2+
//
3+
// check that we mark blocks with `!` locals as unreachable.
4+
// (and currently don't do the same for other uninhabited types)
25
#![feature(never_type)]
36

47
#[derive(Copy, Clone)]

tests/mir-opt/uninhabited_not_read.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// skip-filecheck
22

33
//@ edition: 2021
4-
// In ed 2021 and below, we don't fallback `!` to `()`.
4+
// In ed 2021 and below, we fallback `!` to `()`.
55
// This would introduce a `! -> ()` coercion which would
66
// be UB if we didn't disallow this explicitly.
77

tests/ui/coercion/coerce-loop-issue-122561.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// Regression test for #122561
1+
// Regression test for <https://github.com/rust-lang/rust/issues/122561>.
2+
//
3+
// Tests suggestions for type mismatch of loop expressions.
24

35
fn for_infinite() -> bool {
46
for i in 0.. {

tests/ui/coercion/coerce-loop-issue-122561.stderr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
warning: denote infinite loops with `loop { ... }`
2-
--> $DIR/coerce-loop-issue-122561.rs:47:5
2+
--> $DIR/coerce-loop-issue-122561.rs:49:5
33
|
44
LL | while true {
55
| ^^^^^^^^^^ help: use `loop`
66
|
77
= note: `#[warn(while_true)]` on by default
88

99
warning: denote infinite loops with `loop { ... }`
10-
--> $DIR/coerce-loop-issue-122561.rs:71:5
10+
--> $DIR/coerce-loop-issue-122561.rs:73:5
1111
|
1212
LL | while true {
1313
| ^^^^^^^^^^ help: use `loop`
1414

1515
error[E0308]: mismatched types
16-
--> $DIR/coerce-loop-issue-122561.rs:41:24
16+
--> $DIR/coerce-loop-issue-122561.rs:43:24
1717
|
1818
LL | fn for_in_arg(a: &[(); for x in 0..2 {}]) -> bool {
1919
| ^^^^^^^^^^^^^^^^ expected `usize`, found `()`
@@ -25,7 +25,7 @@ LL | fn for_in_arg(a: &[(); for x in 0..2 {} /* `usize` value */]) -> bool {
2525
| +++++++++++++++++++
2626

2727
error[E0308]: mismatched types
28-
--> $DIR/coerce-loop-issue-122561.rs:4:5
28+
--> $DIR/coerce-loop-issue-122561.rs:6:5
2929
|
3030
LL | fn for_infinite() -> bool {
3131
| ---- expected `bool` because of return type
@@ -43,7 +43,7 @@ LL + /* `bool` value */
4343
|
4444

4545
error[E0308]: mismatched types
46-
--> $DIR/coerce-loop-issue-122561.rs:11:5
46+
--> $DIR/coerce-loop-issue-122561.rs:13:5
4747
|
4848
LL | fn for_finite() -> String {
4949
| ------ expected `String` because of return type
@@ -61,7 +61,7 @@ LL + /* `String` value */
6161
|
6262

6363
error[E0308]: mismatched types
64-
--> $DIR/coerce-loop-issue-122561.rs:18:5
64+
--> $DIR/coerce-loop-issue-122561.rs:20:5
6565
|
6666
LL | fn for_zero_times() -> bool {
6767
| ---- expected `bool` because of return type
@@ -79,7 +79,7 @@ LL + /* `bool` value */
7979
|
8080

8181
error[E0308]: mismatched types
82-
--> $DIR/coerce-loop-issue-122561.rs:25:5
82+
--> $DIR/coerce-loop-issue-122561.rs:27:5
8383
|
8484
LL | fn for_never_type() -> ! {
8585
| - expected `!` because of return type
@@ -98,7 +98,7 @@ LL + /* `loop {}` or `panic!("...")` */
9898
|
9999

100100
error[E0308]: mismatched types
101-
--> $DIR/coerce-loop-issue-122561.rs:33:32
101+
--> $DIR/coerce-loop-issue-122561.rs:35:32
102102
|
103103
LL | fn for_single_line() -> bool { for i in 0.. { return false; } }
104104
| ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
@@ -112,7 +112,7 @@ LL | fn for_single_line() -> bool { for i in 0.. { return false; } /* `bool` val
112112
| ++++++++++++++++++
113113

114114
error[E0308]: mismatched types
115-
--> $DIR/coerce-loop-issue-122561.rs:47:5
115+
--> $DIR/coerce-loop-issue-122561.rs:49:5
116116
|
117117
LL | fn while_inifinite() -> bool {
118118
| ---- expected `bool` because of return type
@@ -131,7 +131,7 @@ LL + /* `bool` value */
131131
|
132132

133133
error[E0308]: mismatched types
134-
--> $DIR/coerce-loop-issue-122561.rs:56:5
134+
--> $DIR/coerce-loop-issue-122561.rs:58:5
135135
|
136136
LL | fn while_finite() -> bool {
137137
| ---- expected `bool` because of return type
@@ -151,7 +151,7 @@ LL + /* `bool` value */
151151
|
152152

153153
error[E0308]: mismatched types
154-
--> $DIR/coerce-loop-issue-122561.rs:64:5
154+
--> $DIR/coerce-loop-issue-122561.rs:66:5
155155
|
156156
LL | fn while_zero_times() -> bool {
157157
| ---- expected `bool` because of return type
@@ -169,7 +169,7 @@ LL + /* `bool` value */
169169
|
170170

171171
error[E0308]: mismatched types
172-
--> $DIR/coerce-loop-issue-122561.rs:71:5
172+
--> $DIR/coerce-loop-issue-122561.rs:73:5
173173
|
174174
LL | fn while_never_type() -> ! {
175175
| - expected `!` because of return type
@@ -188,7 +188,7 @@ LL + /* `loop {}` or `panic!("...")` */
188188
|
189189

190190
error[E0308]: mismatched types
191-
--> $DIR/coerce-loop-issue-122561.rs:85:5
191+
--> $DIR/coerce-loop-issue-122561.rs:87:5
192192
|
193193
LL | / for i in 0.. {
194194
LL | |
@@ -203,7 +203,7 @@ LL + /* `i32` value */
203203
|
204204

205205
error[E0308]: mismatched types
206-
--> $DIR/coerce-loop-issue-122561.rs:92:9
206+
--> $DIR/coerce-loop-issue-122561.rs:94:9
207207
|
208208
LL | / for i in 0..5 {
209209
LL | |
@@ -218,7 +218,7 @@ LL + /* `usize` value */
218218
|
219219

220220
error[E0308]: mismatched types
221-
--> $DIR/coerce-loop-issue-122561.rs:98:9
221+
--> $DIR/coerce-loop-issue-122561.rs:100:9
222222
|
223223
LL | / while false {
224224
LL | |
@@ -233,7 +233,7 @@ LL + /* `usize` value */
233233
|
234234

235235
error[E0308]: mismatched types
236-
--> $DIR/coerce-loop-issue-122561.rs:104:23
236+
--> $DIR/coerce-loop-issue-122561.rs:106:23
237237
|
238238
LL | let _ = |a: &[(); for x in 0..2 {}]| {};
239239
| ^^^^^^^^^^^^^^^^ expected `usize`, found `()`

tests/ui/consts/const-eval/raw-bytes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) };
3434
#[derive(Copy, Clone)]
3535
enum Never {}
3636

37-
// An enum with 3 variants of which some are uninhabited -- so the uninhabited variants *do*
37+
// An enum with 4 variants of which only some are uninhabited -- so the uninhabited variants *do*
3838
// have a discriminant.
3939
enum UninhDiscriminant {
4040
A,
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
// Regression test for <https://github.com/rust-lang/rust/issues/120337>.
2+
//
3+
// This checks that const eval doesn't cause an ICE when reading an uninhabited
4+
// variant. (N.B. this is UB, but not currently detected by rustc)
5+
//
16
//@ check-pass
27
#![feature(never_type)]
8+
39
#[derive(Copy, Clone)]
410
pub enum E { A(!), }
11+
512
pub union U { u: (), e: E, }
13+
614
pub const C: () = {
7-
let E::A(ref a) = unsafe { &(&U { u: () }).e};
15+
let E::A(ref a) = unsafe { &(&U { u: () }).e };
816
};
917

1018
fn main() {}

0 commit comments

Comments
 (0)