Skip to content

Commit

Permalink
Add Miri smoke pass test for ptr_metadata intrinsic
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmcm committed May 28, 2024
1 parent 5a8c1f3 commit 57948c8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/tools/miri/tests/pass/intrinsics/intrinsics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@compile-flags: -Zmiri-permissive-provenance
#![feature(core_intrinsics, layout_for_ptr)]
#![feature(core_intrinsics, layout_for_ptr, ptr_metadata)]
//! Tests for various intrinsics that do not fit anywhere else.

use std::intrinsics;
Expand Down Expand Up @@ -57,4 +57,10 @@ fn main() {
// Make sure that even if the discriminant is stored together with data, the intrinsic returns
// only the discriminant, nothing about the data.
assert_eq!(discriminant(&Some(false)), discriminant(&Some(true)));

let () = intrinsics::ptr_metadata(&[1, 2, 3]);
let len = intrinsics::ptr_metadata(&[1, 2, 3][..]);
assert_eq!(len, 3);
let dyn_meta = intrinsics::ptr_metadata(&[1, 2, 3] as &dyn std::fmt::Debug);
assert_eq!(dyn_meta.size_of(), 12);
}

0 comments on commit 57948c8

Please sign in to comment.