Skip to content

Commit 37af399

Browse files
committed
Update tests
1 parent 7bf791d commit 37af399

34 files changed

+127
-455
lines changed

library/std/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@
246246
#![feature(const_cstr_unchecked)]
247247
#![feature(const_fn_floating_point_arithmetic)]
248248
#![feature(const_fn_fn_ptr_basics)]
249-
#![feature(const_fn_transmute)]
249+
#![cfg_attr(bootstrap, feature(const_fn_transmute))]
250250
#![feature(const_io_structs)]
251251
#![feature(const_ip)]
252252
#![feature(const_ipv4)]

src/test/mir-opt/issues/issue-75439.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// EMIT_MIR issue_75439.foo.MatchBranchSimplification.diff
22

3-
#![feature(const_fn_transmute)]
4-
53
use std::mem::transmute;
64

75
pub fn foo(bytes: [u8; 16]) -> Option<[u8; 4]> {
@@ -16,5 +14,5 @@ pub fn foo(bytes: [u8; 16]) -> Option<[u8; 4]> {
1614
}
1715

1816
fn main() {
19-
let _ = foo([0; 16]);
17+
let _ = foo([0; 16]);
2018
}

src/test/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff

+39-39
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
+ // MIR for `foo` after MatchBranchSimplification
33

44
fn foo(_1: [u8; 16]) -> Option<[u8; 4]> {
5-
debug bytes => _1; // in scope 0 at $DIR/issue-75439.rs:7:12: 7:17
6-
let mut _0: std::option::Option<[u8; 4]>; // return place in scope 0 at $DIR/issue-75439.rs:7:32: 7:47
7-
let _2: [u32; 4]; // in scope 0 at $DIR/issue-75439.rs:9:9: 9:15
8-
let mut _3: [u8; 16]; // in scope 0 at $DIR/issue-75439.rs:9:47: 9:52
9-
let mut _5: [u8; 4]; // in scope 0 at $DIR/issue-75439.rs:12:14: 12:38
10-
let mut _6: u32; // in scope 0 at $DIR/issue-75439.rs:12:33: 12:35
5+
debug bytes => _1; // in scope 0 at $DIR/issue-75439.rs:5:12: 5:17
6+
let mut _0: std::option::Option<[u8; 4]>; // return place in scope 0 at $DIR/issue-75439.rs:5:32: 5:47
7+
let _2: [u32; 4]; // in scope 0 at $DIR/issue-75439.rs:7:9: 7:15
8+
let mut _3: [u8; 16]; // in scope 0 at $DIR/issue-75439.rs:7:47: 7:52
9+
let mut _5: [u8; 4]; // in scope 0 at $DIR/issue-75439.rs:10:14: 10:38
10+
let mut _6: u32; // in scope 0 at $DIR/issue-75439.rs:10:33: 10:35
1111
scope 1 {
12-
debug dwords => _2; // in scope 1 at $DIR/issue-75439.rs:9:9: 9:15
13-
let _4: u32; // in scope 1 at $DIR/issue-75439.rs:11:27: 11:29
12+
debug dwords => _2; // in scope 1 at $DIR/issue-75439.rs:7:9: 7:15
13+
let _4: u32; // in scope 1 at $DIR/issue-75439.rs:9:27: 9:29
1414
scope 3 {
15-
debug ip => _4; // in scope 3 at $DIR/issue-75439.rs:11:27: 11:29
15+
debug ip => _4; // in scope 3 at $DIR/issue-75439.rs:9:27: 9:29
1616
scope 4 {
1717
}
1818
}
@@ -21,67 +21,67 @@
2121
}
2222

2323
bb0: {
24-
StorageLive(_2); // scope 0 at $DIR/issue-75439.rs:9:9: 9:15
25-
StorageLive(_3); // scope 2 at $DIR/issue-75439.rs:9:47: 9:52
26-
_3 = _1; // scope 2 at $DIR/issue-75439.rs:9:47: 9:52
27-
_2 = transmute::<[u8; 16], [u32; 4]>(move _3) -> bb1; // scope 2 at $DIR/issue-75439.rs:9:37: 9:53
24+
StorageLive(_2); // scope 0 at $DIR/issue-75439.rs:7:9: 7:15
25+
StorageLive(_3); // scope 2 at $DIR/issue-75439.rs:7:47: 7:52
26+
_3 = _1; // scope 2 at $DIR/issue-75439.rs:7:47: 7:52
27+
_2 = transmute::<[u8; 16], [u32; 4]>(move _3) -> bb1; // scope 2 at $DIR/issue-75439.rs:7:37: 7:53
2828
// mir::Constant
29-
// + span: $DIR/issue-75439.rs:9:37: 9:46
29+
// + span: $DIR/issue-75439.rs:7:37: 7:46
3030
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn([u8; 16]) -> [u32; 4] {std::intrinsics::transmute::<[u8; 16], [u32; 4]>}, val: Value(Scalar(<ZST>)) }
3131
}
3232

3333
bb1: {
34-
StorageDead(_3); // scope 2 at $DIR/issue-75439.rs:9:52: 9:53
35-
switchInt(_2[0 of 4]) -> [0_u32: bb2, otherwise: bb4]; // scope 1 at $DIR/issue-75439.rs:11:13: 11:14
34+
StorageDead(_3); // scope 2 at $DIR/issue-75439.rs:7:52: 7:53
35+
switchInt(_2[0 of 4]) -> [0_u32: bb2, otherwise: bb4]; // scope 1 at $DIR/issue-75439.rs:9:13: 9:14
3636
}
3737

3838
bb2: {
39-
switchInt(_2[1 of 4]) -> [0_u32: bb3, otherwise: bb4]; // scope 1 at $DIR/issue-75439.rs:11:16: 11:17
39+
switchInt(_2[1 of 4]) -> [0_u32: bb3, otherwise: bb4]; // scope 1 at $DIR/issue-75439.rs:9:16: 9:17
4040
}
4141

4242
bb3: {
43-
switchInt(_2[2 of 4]) -> [0_u32: bb6, 4294901760_u32: bb7, otherwise: bb4]; // scope 1 at $DIR/issue-75439.rs:11:19: 11:20
43+
switchInt(_2[2 of 4]) -> [0_u32: bb6, 4294901760_u32: bb7, otherwise: bb4]; // scope 1 at $DIR/issue-75439.rs:9:19: 9:20
4444
}
4545

4646
bb4: {
47-
discriminant(_0) = 0; // scope 1 at $DIR/issue-75439.rs:14:9: 14:13
48-
goto -> bb9; // scope 1 at $DIR/issue-75439.rs:11:5: 15:6
47+
discriminant(_0) = 0; // scope 1 at $DIR/issue-75439.rs:12:9: 12:13
48+
goto -> bb9; // scope 1 at $DIR/issue-75439.rs:9:5: 13:6
4949
}
5050

5151
bb5: {
52-
StorageLive(_5); // scope 3 at $DIR/issue-75439.rs:12:14: 12:38
53-
StorageLive(_6); // scope 4 at $DIR/issue-75439.rs:12:33: 12:35
54-
_6 = _4; // scope 4 at $DIR/issue-75439.rs:12:33: 12:35
55-
_5 = transmute::<u32, [u8; 4]>(move _6) -> bb8; // scope 4 at $DIR/issue-75439.rs:12:23: 12:36
52+
StorageLive(_5); // scope 3 at $DIR/issue-75439.rs:10:14: 10:38
53+
StorageLive(_6); // scope 4 at $DIR/issue-75439.rs:10:33: 10:35
54+
_6 = _4; // scope 4 at $DIR/issue-75439.rs:10:33: 10:35
55+
_5 = transmute::<u32, [u8; 4]>(move _6) -> bb8; // scope 4 at $DIR/issue-75439.rs:10:23: 10:36
5656
// mir::Constant
57-
// + span: $DIR/issue-75439.rs:12:23: 12:32
57+
// + span: $DIR/issue-75439.rs:10:23: 10:32
5858
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u32) -> [u8; 4] {std::intrinsics::transmute::<u32, [u8; 4]>}, val: Value(Scalar(<ZST>)) }
5959
}
6060

6161
bb6: {
62-
StorageLive(_4); // scope 1 at $DIR/issue-75439.rs:11:27: 11:29
63-
_4 = _2[3 of 4]; // scope 1 at $DIR/issue-75439.rs:11:27: 11:29
64-
goto -> bb5; // scope 1 at $DIR/issue-75439.rs:11:5: 15:6
62+
StorageLive(_4); // scope 1 at $DIR/issue-75439.rs:9:27: 9:29
63+
_4 = _2[3 of 4]; // scope 1 at $DIR/issue-75439.rs:9:27: 9:29
64+
goto -> bb5; // scope 1 at $DIR/issue-75439.rs:9:5: 13:6
6565
}
6666

6767
bb7: {
68-
StorageLive(_4); // scope 1 at $DIR/issue-75439.rs:11:27: 11:29
69-
_4 = _2[3 of 4]; // scope 1 at $DIR/issue-75439.rs:11:27: 11:29
70-
goto -> bb5; // scope 1 at $DIR/issue-75439.rs:11:5: 15:6
68+
StorageLive(_4); // scope 1 at $DIR/issue-75439.rs:9:27: 9:29
69+
_4 = _2[3 of 4]; // scope 1 at $DIR/issue-75439.rs:9:27: 9:29
70+
goto -> bb5; // scope 1 at $DIR/issue-75439.rs:9:5: 13:6
7171
}
7272

7373
bb8: {
74-
StorageDead(_6); // scope 4 at $DIR/issue-75439.rs:12:35: 12:36
75-
((_0 as Some).0: [u8; 4]) = move _5; // scope 3 at $DIR/issue-75439.rs:12:9: 12:39
76-
discriminant(_0) = 1; // scope 3 at $DIR/issue-75439.rs:12:9: 12:39
77-
StorageDead(_5); // scope 3 at $DIR/issue-75439.rs:12:38: 12:39
78-
StorageDead(_4); // scope 1 at $DIR/issue-75439.rs:13:5: 13:6
79-
goto -> bb9; // scope 1 at $DIR/issue-75439.rs:11:5: 15:6
74+
StorageDead(_6); // scope 4 at $DIR/issue-75439.rs:10:35: 10:36
75+
((_0 as Some).0: [u8; 4]) = move _5; // scope 3 at $DIR/issue-75439.rs:10:9: 10:39
76+
discriminant(_0) = 1; // scope 3 at $DIR/issue-75439.rs:10:9: 10:39
77+
StorageDead(_5); // scope 3 at $DIR/issue-75439.rs:10:38: 10:39
78+
StorageDead(_4); // scope 1 at $DIR/issue-75439.rs:11:5: 11:6
79+
goto -> bb9; // scope 1 at $DIR/issue-75439.rs:9:5: 13:6
8080
}
8181

8282
bb9: {
83-
StorageDead(_2); // scope 0 at $DIR/issue-75439.rs:16:1: 16:2
84-
return; // scope 0 at $DIR/issue-75439.rs:16:2: 16:2
83+
StorageDead(_2); // scope 0 at $DIR/issue-75439.rs:14:1: 14:2
84+
return; // scope 0 at $DIR/issue-75439.rs:14:2: 14:2
8585
}
8686
}
8787

src/test/ui/consts/const-eval/const_transmute.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22

3-
#![feature(const_fn_union)]
43
#![allow(dead_code)]
54

65
#[repr(C)]

src/test/ui/consts/const-eval/feature-gate-const_fn_union.rs

-11
This file was deleted.

src/test/ui/consts/const-eval/feature-gate-const_fn_union.stderr

-12
This file was deleted.

src/test/ui/consts/const-eval/issue-49296.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// issue-49296: Unsafe shenigans in constants can result in missing errors
22

3-
#![feature(const_fn_union)]
43
#![feature(const_fn_trait_bound)]
54

65
const unsafe fn transmute<T: Copy, U: Copy>(t: T) -> U {

src/test/ui/consts/const-eval/issue-49296.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0080]: evaluation of constant value failed
2-
--> $DIR/issue-49296.rs:19:16
2+
--> $DIR/issue-49296.rs:18:16
33
|
44
LL | const X: u64 = *wat(42);
55
| ^^^^^^^^ pointer to alloc2 was dereferenced after this allocation got freed

src/test/ui/consts/const-eval/promoted_const_fn_fail.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(const_fn_union)]
2-
31
#![allow(const_err)]
42

53
#[repr(C)]

src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0716]: temporary value dropped while borrowed
2-
--> $DIR/promoted_const_fn_fail.rs:21:27
2+
--> $DIR/promoted_const_fn_fail.rs:19:27
33
|
44
LL | let x: &'static u8 = &(bar() + 1);
55
| ----------- ^^^^^^^^^^^ creates a temporary which is freed while still in use

src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(const_fn_union)]
2-
31
#![deny(const_err)]
42

53
#[repr(C)]

src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0716]: temporary value dropped while borrowed
2-
--> $DIR/promoted_const_fn_fail_deny_const_err.rs:22:27
2+
--> $DIR/promoted_const_fn_fail_deny_const_err.rs:20:27
33
|
44
LL | let x: &'static u8 = &(bar() + 1);
55
| ----------- ^^^^^^^^^^^ creates a temporary which is freed while still in use

src/test/ui/consts/const-eval/ref_to_int_match.32bit.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0080]: it is undefined behavior to use this value
2-
--> $DIR/ref_to_int_match.rs:26:1
2+
--> $DIR/ref_to_int_match.rs:25:1
33
|
44
LL | const BAR: Int = unsafe { Foo { r: &42 }.f };
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc3, but expected initialized plain (non-pointer) bytes
@@ -10,13 +10,13 @@ LL | const BAR: Int = unsafe { Foo { r: &42 }.f };
1010
}
1111

1212
error: could not evaluate constant pattern
13-
--> $DIR/ref_to_int_match.rs:8:14
13+
--> $DIR/ref_to_int_match.rs:7:14
1414
|
1515
LL | 10..=BAR => {},
1616
| ^^^
1717

1818
error: could not evaluate constant pattern
19-
--> $DIR/ref_to_int_match.rs:8:14
19+
--> $DIR/ref_to_int_match.rs:7:14
2020
|
2121
LL | 10..=BAR => {},
2222
| ^^^

src/test/ui/consts/const-eval/ref_to_int_match.64bit.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0080]: it is undefined behavior to use this value
2-
--> $DIR/ref_to_int_match.rs:26:1
2+
--> $DIR/ref_to_int_match.rs:25:1
33
|
44
LL | const BAR: Int = unsafe { Foo { r: &42 }.f };
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc3, but expected initialized plain (non-pointer) bytes
@@ -10,13 +10,13 @@ LL | const BAR: Int = unsafe { Foo { r: &42 }.f };
1010
}
1111

1212
error: could not evaluate constant pattern
13-
--> $DIR/ref_to_int_match.rs:8:14
13+
--> $DIR/ref_to_int_match.rs:7:14
1414
|
1515
LL | 10..=BAR => {},
1616
| ^^^
1717

1818
error: could not evaluate constant pattern
19-
--> $DIR/ref_to_int_match.rs:8:14
19+
--> $DIR/ref_to_int_match.rs:7:14
2020
|
2121
LL | 10..=BAR => {},
2222
| ^^^

src/test/ui/consts/const-eval/ref_to_int_match.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// stderr-per-bitwidth
2-
#![feature(const_fn_union)]
32

43
fn main() {
54
let n: Int = 40;

src/test/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error[E0080]: evaluation of constant value failed
2-
--> $DIR/validate_uninhabited_zsts.rs:5:14
2+
--> $DIR/validate_uninhabited_zsts.rs:4:14
33
|
44
LL | unsafe { std::mem::transmute(()) }
55
| ^^^^^^^^^^^^^^^^^^^^^^^
66
| |
77
| transmuting to uninhabited type
8-
| inside `foo` at $DIR/validate_uninhabited_zsts.rs:5:14
8+
| inside `foo` at $DIR/validate_uninhabited_zsts.rs:4:14
99
...
1010
LL | const FOO: [Empty; 3] = [foo(); 3];
11-
| ----- inside `FOO` at $DIR/validate_uninhabited_zsts.rs:14:26
11+
| ----- inside `FOO` at $DIR/validate_uninhabited_zsts.rs:13:26
1212

1313
error[E0080]: it is undefined behavior to use this value
14-
--> $DIR/validate_uninhabited_zsts.rs:17:1
14+
--> $DIR/validate_uninhabited_zsts.rs:16:1
1515
|
1616
LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at [0]: encountered a value of uninhabited type Empty
@@ -20,7 +20,7 @@ LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
2020
= note: the raw bytes of the constant (size: 0, align: 1) {}
2121

2222
warning: the type `!` does not permit zero-initialization
23-
--> $DIR/validate_uninhabited_zsts.rs:5:14
23+
--> $DIR/validate_uninhabited_zsts.rs:4:14
2424
|
2525
LL | unsafe { std::mem::transmute(()) }
2626
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -32,7 +32,7 @@ LL | unsafe { std::mem::transmute(()) }
3232
= note: the `!` type has no valid value
3333

3434
warning: the type `Empty` does not permit zero-initialization
35-
--> $DIR/validate_uninhabited_zsts.rs:17:35
35+
--> $DIR/validate_uninhabited_zsts.rs:16:35
3636
|
3737
LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
3838
| ^^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error[E0080]: evaluation of constant value failed
2-
--> $DIR/validate_uninhabited_zsts.rs:5:14
2+
--> $DIR/validate_uninhabited_zsts.rs:4:14
33
|
44
LL | unsafe { std::mem::transmute(()) }
55
| ^^^^^^^^^^^^^^^^^^^^^^^
66
| |
77
| transmuting to uninhabited type
8-
| inside `foo` at $DIR/validate_uninhabited_zsts.rs:5:14
8+
| inside `foo` at $DIR/validate_uninhabited_zsts.rs:4:14
99
...
1010
LL | const FOO: [Empty; 3] = [foo(); 3];
11-
| ----- inside `FOO` at $DIR/validate_uninhabited_zsts.rs:14:26
11+
| ----- inside `FOO` at $DIR/validate_uninhabited_zsts.rs:13:26
1212

1313
error[E0080]: it is undefined behavior to use this value
14-
--> $DIR/validate_uninhabited_zsts.rs:17:1
14+
--> $DIR/validate_uninhabited_zsts.rs:16:1
1515
|
1616
LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at [0]: encountered a value of uninhabited type Empty
@@ -20,7 +20,7 @@ LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
2020
= note: the raw bytes of the constant (size: 0, align: 1) {}
2121

2222
warning: the type `!` does not permit zero-initialization
23-
--> $DIR/validate_uninhabited_zsts.rs:5:14
23+
--> $DIR/validate_uninhabited_zsts.rs:4:14
2424
|
2525
LL | unsafe { std::mem::transmute(()) }
2626
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -32,7 +32,7 @@ LL | unsafe { std::mem::transmute(()) }
3232
= note: the `!` type has no valid value
3333

3434
warning: the type `Empty` does not permit zero-initialization
35-
--> $DIR/validate_uninhabited_zsts.rs:17:35
35+
--> $DIR/validate_uninhabited_zsts.rs:16:35
3636
|
3737
LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
3838
| ^^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// stderr-per-bitwidth
2-
#![feature(const_fn_transmute)]
32

43
const fn foo() -> ! {
54
unsafe { std::mem::transmute(()) }

src/test/ui/consts/const-fn-not-safe-for-const.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Test that we can't call random fns in a const fn or do other bad things.
22

3-
#![feature(const_fn_transmute)]
4-
53
use std::mem::transmute;
64

7-
fn random() -> u32 { 0 }
5+
fn random() -> u32 {
6+
0
7+
}
88

99
const fn sub(x: &u32) -> usize {
1010
unsafe { transmute(x) }
@@ -18,12 +18,12 @@ static Y: u32 = 0;
1818

1919
const fn get_Y() -> u32 {
2020
Y
21-
//~^ ERROR E0013
21+
//~^ ERROR E0013
2222
}
2323

2424
const fn get_Y_addr() -> &'static u32 {
2525
&Y
26-
//~^ ERROR E0013
26+
//~^ ERROR E0013
2727
}
2828

2929
const fn get() -> u32 {

src/test/ui/consts/issue-69532.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// run-pass
2-
#![feature(const_fn_transmute)]
32

43
const fn make_nans() -> (f64, f64, f32, f32) {
54
let nan1: f64 = unsafe { std::mem::transmute(0x7FF0_0001_0000_0001u64) };

0 commit comments

Comments
 (0)