Skip to content

Commit fede517

Browse files
committed
Update a few tests with their improved diagnostic messages
1 parent a987e1a commit fede517

8 files changed

+24
-19
lines changed

src/test/ui/consts/const-err4.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ union Foo {
1616

1717
enum Bar {
1818
Boo = [unsafe { Foo { b: () }.a }; 4][3],
19-
//~^ ERROR could not evaluate enum discriminant
19+
//~^ ERROR constant evaluation of enum discriminant resulted in non-integer
2020
}
2121

2222
fn main() {

src/test/ui/consts/const-err4.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0080]: could not evaluate enum discriminant
1+
error[E0080]: constant evaluation of enum discriminant resulted in non-integer
22
--> $DIR/const-err4.rs:18:11
33
|
44
LL | Boo = [unsafe { Foo { b: () }.a }; 4][3],
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

77
error: aborting due to previous error
88

src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn main() {
3737
//~^ ERROR this constant likely exhibits undefined behavior
3838

3939
const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 };
40-
//~^ ERROR this constant cannot be used
40+
//~^ ERROR this constant likely exhibits undefined behavior
4141

4242
const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 };
4343
//~^ ERROR this constant cannot be used
@@ -52,7 +52,7 @@ fn main() {
5252
//~^ ERROR this constant likely exhibits undefined behavior
5353

5454
const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 };
55-
//~^ ERROR this constant cannot be used
55+
//~^ ERROR this constant likely exhibits undefined behavior
5656

5757
const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 };
5858
//~^ ERROR this constant cannot be used

src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uin
4040
|
4141
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
4242

43-
error: this constant cannot be used
43+
error[E0080]: this constant likely exhibits undefined behavior
4444
--> $DIR/const-pointer-values-in-various-types.rs:39:5
4545
|
4646
LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 };
47-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
47+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain bits
48+
|
49+
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
4850

4951
error: this constant cannot be used
5052
--> $DIR/const-pointer-values-in-various-types.rs:42:5
@@ -78,11 +80,13 @@ LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int
7880
|
7981
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
8082

81-
error: this constant cannot be used
83+
error[E0080]: this constant likely exhibits undefined behavior
8284
--> $DIR/const-pointer-values-in-various-types.rs:54:5
8385
|
8486
LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 };
85-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
87+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain bits
88+
|
89+
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
8690

8791
error: this constant cannot be used
8892
--> $DIR/const-pointer-values-in-various-types.rs:57:5

src/test/ui/consts/const-eval/union-const-eval-field.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const fn read_field2() -> Field2 {
3434
}
3535

3636
const fn read_field3() -> Field3 {
37-
const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR cannot be used
37+
const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR likely exhibits undefined behavior
3838
FIELD3
3939
}
4040

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
error: this constant cannot be used
1+
error[E0080]: this constant likely exhibits undefined behavior
22
--> $DIR/union-const-eval-field.rs:37:5
33
|
4-
LL | const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR cannot be used
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
4+
LL | const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR likely exhibits undefined behavior
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain bits
66
|
7-
= note: #[deny(const_err)] on by default
7+
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
88

99
error: aborting due to previous error
1010

11+
For more information about this error, try `rustc --explain E0080`.

src/test/ui/consts/const-eval/union-ice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ union DummyUnion {
2020

2121
const UNION: DummyUnion = DummyUnion { field1: 1065353216 };
2222

23-
const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR this constant cannot be used
23+
const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR likely exhibits undefined behavior
2424

2525
const FIELD_PATH: Struct = Struct { //~ ERROR this constant likely exhibits undefined behavior
2626
a: 42,

src/test/ui/consts/const-eval/union-ice.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error: this constant cannot be used
1+
error[E0080]: this constant likely exhibits undefined behavior
22
--> $DIR/union-ice.rs:23:1
33
|
4-
LL | const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR this constant cannot be used
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
4+
LL | const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR likely exhibits undefined behavior
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain bits
66
|
7-
= note: #[deny(const_err)] on by default
7+
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
88

99
error[E0080]: this constant likely exhibits undefined behavior
1010
--> $DIR/union-ice.rs:25:1

0 commit comments

Comments
 (0)