rust/tests/run-pass/intrinsics.rs
Dylan MacKenzie 1ceb81b345 Use in-core implementation of type_name.
We bump `rust-version` to pick up the new impl from
https://github.com/rust-lang/rust/pull/61498 and add a test.
2019-06-05 22:36:53 -07:00

16 lines
463 B
Rust

#![feature(core_intrinsics)]
use std::intrinsics::type_name;
use std::mem::{size_of, size_of_val};
fn main() {
assert_eq!(size_of::<Option<i32>>(), 8);
assert_eq!(size_of_val(&()), 0);
assert_eq!(size_of_val(&42), 4);
assert_eq!(size_of_val(&[] as &[i32]), 0);
assert_eq!(size_of_val(&[1, 2, 3] as &[i32]), 12);
assert_eq!(size_of_val("foobar"), 6);
assert_eq!(unsafe { type_name::<Option<i32>>() }, "core::option::Option<i32>");
}