Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
091433d
commit f80b9ac
Showing
24 changed files
with
1,443 additions
and
1 deletion.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
src/test/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/invalid-patterns.rs:29:21 | ||
| | ||
LL | get_flag::<false, 0xFF>(); | ||
| ^^^^ expected `char`, found `u8` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/invalid-patterns.rs:31:14 | ||
| | ||
LL | get_flag::<7, 'c'>(); | ||
| ^ expected `bool`, found integer | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/invalid-patterns.rs:33:14 | ||
| | ||
LL | get_flag::<42, 0x5ad>(); | ||
| ^^ expected `bool`, found integer | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/invalid-patterns.rs:33:18 | ||
| | ||
LL | get_flag::<42, 0x5ad>(); | ||
| ^^^^^ expected `char`, found `u8` | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/invalid-patterns.rs:38:21 | ||
| | ||
LL | get_flag::<false, { unsafe { char_raw.character } }>(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 4, align: 4) { | ||
__ __ __ __ │ ░░░░ | ||
} | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/invalid-patterns.rs:40:14 | ||
| | ||
LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x42, but expected a boolean | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 1, align: 1) { | ||
42 │ B | ||
} | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/invalid-patterns.rs:42:14 | ||
| | ||
LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x42, but expected a boolean | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 1, align: 1) { | ||
42 │ B | ||
} | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/invalid-patterns.rs:42:47 | ||
| | ||
LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 4, align: 4) { | ||
__ __ __ __ │ ░░░░ | ||
} | ||
|
||
error: aborting due to 8 previous errors | ||
|
||
Some errors have detailed explanations: E0080, E0308. | ||
For more information about an error, try `rustc --explain E0080`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/const-err4.rs:9:11 | ||
| | ||
LL | Boo = [unsafe { Foo { b: () }.a }; 4][3], | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 4, align: 4) { | ||
__ __ __ __ │ ░░░░ | ||
} | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
14 changes: 14 additions & 0 deletions
14
src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/alloc_intrinsic_uninit.rs:9:1 | ||
| | ||
LL | const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes at .<deref>, but expected initialized plain (non-pointer) bytes | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 4, align: 4) { | ||
╾─alloc1──╼ │ ╾──╼ | ||
} | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
26 changes: 26 additions & 0 deletions
26
src/test/ui/consts/const-eval/ref_to_int_match.32bit.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ref_to_int_match.rs:26:1 | ||
| | ||
LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc2, but expected initialized plain (non-pointer) bytes | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 4, align: 4) { | ||
╾─alloc2──╼ │ ╾──╼ | ||
} | ||
|
||
error: could not evaluate constant pattern | ||
--> $DIR/ref_to_int_match.rs:8:14 | ||
| | ||
LL | 10..=BAR => {}, | ||
| ^^^ | ||
|
||
error: could not evaluate constant pattern | ||
--> $DIR/ref_to_int_match.rs:8:14 | ||
| | ||
LL | 10..=BAR => {}, | ||
| ^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
14 changes: 14 additions & 0 deletions
14
src/test/ui/consts/const-eval/transmute-const.32bit.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/transmute-const.rs:4:1 | ||
| | ||
LL | static FOO: bool = unsafe { mem::transmute(3u8) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x03, but expected a boolean | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 1, align: 1) { | ||
03 │ . | ||
} | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-enum.rs:24:1 | ||
| | ||
LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x00000001 at .<enum-tag>, but expected a valid enum tag | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 4, align: 4) { | ||
01 00 00 00 │ .... | ||
} | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-enum.rs:27:1 | ||
| | ||
LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc8 at .<enum-tag>, but expected initialized plain (non-pointer) bytes | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 4, align: 4) { | ||
╾─alloc8──╼ │ ╾──╼ | ||
} | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-enum.rs:30:1 | ||
| | ||
LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc12 at .0.<enum-tag>, but expected initialized plain (non-pointer) bytes | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 4, align: 4) { | ||
╾─alloc12─╼ │ ╾──╼ | ||
} | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-enum.rs:42:1 | ||
| | ||
LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x00000000 at .<enum-tag>, but expected a valid enum tag | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 4, align: 4) { | ||
00 00 00 00 │ .... | ||
} | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-enum.rs:44:1 | ||
| | ||
LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc18 at .<enum-tag>, but expected initialized plain (non-pointer) bytes | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 4, align: 4) { | ||
╾─alloc18─╼ │ ╾──╼ | ||
} | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-enum.rs:47:1 | ||
| | ||
LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc22 at .0.<enum-tag>, but expected initialized plain (non-pointer) bytes | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 4, align: 4) { | ||
╾─alloc22─╼ │ ╾──╼ | ||
} | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-enum.rs:56:1 | ||
| | ||
LL | const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes at .<enum-tag>, but expected initialized plain (non-pointer) bytes | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 4, align: 4) { | ||
__ __ __ __ │ ░░░░ | ||
} | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-enum.rs:60:1 | ||
| | ||
LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc28 at .<enum-tag>, but expected initialized plain (non-pointer) bytes | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 4, align: 4) { | ||
╾─alloc28─╼ │ ╾──╼ | ||
} | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-enum.rs:77:1 | ||
| | ||
LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of the never type `!` at .<enum-variant(B)>.0 | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 1, align: 1) { | ||
01 │ . | ||
} | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-enum.rs:79:1 | ||
| | ||
LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of uninhabited type Never at .<enum-variant(D)>.0 | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 1, align: 1) { | ||
03 │ . | ||
} | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-enum.rs:87:1 | ||
| | ||
LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0xffffffff at .<enum-variant(Some)>.0.1, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 8, align: 4) { | ||
78 00 00 00 ff ff ff ff │ x....... | ||
} | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-enum.rs:92:1 | ||
| | ||
LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of uninhabited type Never at .<enum-variant(Ok)>.0.1 | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 8, align: 4) { | ||
00 00 00 00 00 00 00 00 │ ........ | ||
} | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-enum.rs:94:1 | ||
| | ||
LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of the never type `!` at .<enum-variant(Ok)>.0.1 | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 8, align: 4) { | ||
00 00 00 00 00 00 00 00 │ ........ | ||
} | ||
|
||
error: aborting due to 13 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-int-array.rs:14:1 | ||
| | ||
LL | / const UNINIT_INT_0: [u32; 3] = unsafe { | ||
LL | | | ||
LL | | | ||
LL | | [ | ||
... | | ||
LL | | ] | ||
LL | | }; | ||
| |__^ type validation failed: encountered uninitialized bytes at [0] | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 12, align: 4) { | ||
__ __ __ __ 01 00 00 00 02 00 00 00 │ ░░░░........ | ||
} | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-int-array.rs:23:1 | ||
| | ||
LL | / const UNINIT_INT_1: [u32; 3] = unsafe { | ||
LL | | | ||
LL | | | ||
LL | | mem::transmute( | ||
... | | ||
LL | | ) | ||
LL | | }; | ||
| |__^ type validation failed: encountered uninitialized bytes at [1] | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 12, align: 4) { | ||
00 00 00 00 01 __ 01 01 02 02 __ 02 │ .....░....░. | ||
} | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-int-array.rs:43:1 | ||
| | ||
LL | / const UNINIT_INT_2: [u32; 3] = unsafe { | ||
LL | | | ||
LL | | | ||
LL | | mem::transmute( | ||
... | | ||
LL | | ) | ||
LL | | }; | ||
| |__^ type validation failed: encountered uninitialized bytes at [2] | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: 12, align: 4) { | ||
00 00 00 00 01 01 01 01 02 02 02 __ │ ...........░ | ||
} | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
Oops, something went wrong.