Skip to content

Commit a099639

Browse files
committed
Update UI tests for enums that shrank
1 parent ab60636 commit a099639

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

tests/ui/consts/const-eval/ub-enum.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute
9595

9696
// All variants are uninhabited but also have data.
9797
// Use `0` as constant to make behavior endianness-independent.
98-
const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) };
98+
const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u32) };
9999
//~^ ERROR uninhabited enum variant
100-
const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) };
100+
const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u32) };
101101
//~^ ERROR uninhabited enum variant
102102

103103
const TEST_ICE_89765: () = {

tests/ui/consts/const-eval/ub-enum.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran
111111
error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
112112
--> $DIR/ub-enum.rs:98:77
113113
|
114-
LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) };
114+
LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u32) };
115115
| ^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_UNINHABITED_WITH_DATA1` failed here
116116

117117
error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
118118
--> $DIR/ub-enum.rs:100:77
119119
|
120-
LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) };
120+
LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u32) };
121121
| ^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_UNINHABITED_WITH_DATA2` failed here
122122

123123
error[E0080]: read discriminant of an uninhabited enum variant

tests/ui/layout/debug.stderr

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | union EmptyUnion {}
55
| ^^^^^^^^^^^^^^^^^^^
66

77
error: layout_of(E) = Layout {
8-
size: Size(12 bytes),
8+
size: Size(8 bytes),
99
align: AbiAlign {
1010
abi: Align(4 bytes),
1111
},
@@ -64,23 +64,36 @@ error: layout_of(E) = Layout {
6464
randomization_seed: $SEED,
6565
},
6666
Layout {
67-
size: Size(12 bytes),
67+
size: Size(8 bytes),
6868
align: AbiAlign {
6969
abi: Align(4 bytes),
7070
},
71-
backend_repr: Memory {
72-
sized: true,
73-
},
71+
backend_repr: ScalarPair(
72+
Initialized {
73+
value: Int(
74+
I32,
75+
true,
76+
),
77+
valid_range: 0..=4294967295,
78+
},
79+
Initialized {
80+
value: Int(
81+
I32,
82+
true,
83+
),
84+
valid_range: 0..=4294967295,
85+
},
86+
),
7487
fields: Arbitrary {
7588
offsets: [
76-
Size(4 bytes),
77-
Size(4 bytes),
7889
Size(8 bytes),
90+
Size(0 bytes),
91+
Size(4 bytes),
7992
],
8093
memory_index: [
94+
2,
8195
0,
8296
1,
83-
2,
8497
],
8598
},
8699
largest_niche: None,
@@ -493,7 +506,7 @@ LL | union P3 { x: F32x4 }
493506
| ^^^^^^^^
494507

495508
error: layout_of(P4) = Layout {
496-
size: Size(12 bytes),
509+
size: Size(8 bytes),
497510
align: AbiAlign {
498511
abi: Align(1 bytes),
499512
},

tests/ui/layout/enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ enum UninhabitedVariantAlign { //~ERROR: abi: Align(2 bytes)
1212
}
1313

1414
#[rustc_layout(size)]
15-
enum UninhabitedVariantSpace { //~ERROR: size: Size(16 bytes)
15+
enum UninhabitedVariantSpace { //~ERROR: size: Size(15 bytes)
1616
A,
1717
B([u8; 15], !), // make sure there is space being reserved for this field.
1818
}

tests/ui/layout/enum.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: align: AbiAlign { abi: Align(2 bytes) }
44
LL | enum UninhabitedVariantAlign {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

7-
error: size: Size(16 bytes)
7+
error: size: Size(15 bytes)
88
--> $DIR/enum.rs:15:1
99
|
1010
LL | enum UninhabitedVariantSpace {

0 commit comments

Comments
 (0)