-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #82175 - RalfJung:invalid-fn-ptr, r=oli-obk
validation: fix invalid-fn-ptr error message #82061 changed the code here to print an `ImmTy` instead of a `ScalarMaybeUninit`; that was an accident. So go back to printing a `ScalarMaybeUninit`. r? ```@oli-obk```
- Loading branch information
Showing
3 changed files
with
41 additions
and
11 deletions.
There are no files selected for viewing
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
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
36 changes: 26 additions & 10 deletions
36
src/test/ui/consts/const-eval/ub-ref.stderr → ...st/ui/consts/const-eval/ub-ref-ptr.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 |
---|---|---|
@@ -1,75 +1,91 @@ | ||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-ref.rs:6:1 | ||
--> $DIR/ub-ref-ptr.rs:12:1 | ||
| | ||
LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered an unaligned reference (required 2 byte alignment but found 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. | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-ref.rs:10:1 | ||
--> $DIR/ub-ref-ptr.rs:16:1 | ||
| | ||
LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered an unaligned box (required 2 byte alignment but found 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. | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-ref.rs:14:1 | ||
--> $DIR/ub-ref-ptr.rs:20:1 | ||
| | ||
LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a NULL reference | ||
| | ||
= 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. | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-ref.rs:17:1 | ||
--> $DIR/ub-ref-ptr.rs:23:1 | ||
| | ||
LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a NULL box | ||
| | ||
= 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. | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-ref.rs:23:1 | ||
--> $DIR/ub-ref-ptr.rs:29:1 | ||
| | ||
LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc14, 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. | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-ref.rs:26:1 | ||
--> $DIR/ub-ref-ptr.rs:32:1 | ||
| | ||
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer at .<deref>, but expected 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. | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-ref.rs:29:1 | ||
--> $DIR/ub-ref-ptr.rs:35:1 | ||
| | ||
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer at .<deref>, but expected 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. | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-ref.rs:32:1 | ||
--> $DIR/ub-ref-ptr.rs:38:1 | ||
| | ||
LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (created from integer) | ||
| | ||
= 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. | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-ref.rs:35:1 | ||
--> $DIR/ub-ref-ptr.rs:41:1 | ||
| | ||
LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling box (created from integer) | ||
| | ||
= 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. | ||
|
||
error: aborting due to 9 previous errors | ||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-ref-ptr.rs:44:1 | ||
| | ||
LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized raw pointer | ||
| | ||
= 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. | ||
|
||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/ub-ref-ptr.rs:46:1 | ||
| | ||
LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected a function pointer | ||
| | ||
= 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. | ||
|
||
error: aborting due to 11 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0080`. |