Skip to content

Commit 3c9a699

Browse files
committed
add const test for ptr::metadata
1 parent 384d26f commit 3c9a699

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: tests/ui/consts/const-eval/ub-wide-ptr.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ignore-tidy-linelength
22
#![allow(unused)]
33

4-
use std::mem;
4+
use std::{ptr, mem};
55

66
// Strip out raw byte dumps to make comparison platform-independent:
77
//@ normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
@@ -145,6 +145,8 @@ const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92
145145
const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
146146
//~^ ERROR it is undefined behavior to use this value
147147
const RAW_TRAIT_OBJ_CONTENT_INVALID: *const dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) } as *const dyn Trait; // ok because raw
148+
// Officially blessed way to get the vtable
149+
const DYN_METADATA: DynMetadata<dyn Send> = ptr::metadata::<dyn Send>(ptr::null::<i32>());
148150

149151
// Const eval fails for these, so they need to be statics to error.
150152
static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe {

0 commit comments

Comments
 (0)