Skip to content

Commit 6ab0147

Browse files
authored
Merge pull request #761 from ecstatic-morse/type-name
Add a test for the new `type_name` intrinsic.
2 parents f1730d1 + 1ceb81b commit 6ab0147

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
021a5033098ff0e3f7126acc7ac35149d325f16d
1+
7cdaffd7962c4aae0cadd82baa241901b03f9458

src/intrinsic.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc::ty;
55

66
use crate::{
77
PlaceTy, OpTy, ImmTy, Immediate, Scalar, ScalarMaybeUndef, Tag,
8-
OperatorEvalContextExt, MiriMemoryKind,
8+
OperatorEvalContextExt
99
};
1010

1111
impl<'a, 'mir, 'tcx> EvalContextExt<'a, 'mir, 'tcx> for crate::MiriEvalContext<'a, 'mir, 'tcx> {}
@@ -398,14 +398,6 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
398398
)?;
399399
}
400400

401-
"type_name" => {
402-
let ty = substs.type_at(0);
403-
let ty_name = ty.to_string();
404-
let ptr = this.memory_mut().allocate_static_bytes(ty_name.as_bytes(), MiriMemoryKind::Static.into());
405-
let value = Immediate::new_slice(Scalar::Ptr(ptr), ty_name.len() as u64, this);
406-
this.write_immediate(value, dest)?;
407-
}
408-
409401
"unchecked_div" => {
410402
let l = this.read_immediate(args[0])?;
411403
let r = this.read_immediate(args[1])?;

tests/run-pass/intrinsics.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#![feature(core_intrinsics)]
2+
3+
use std::intrinsics::type_name;
14
use std::mem::{size_of, size_of_val};
25

36
fn main() {
@@ -7,4 +10,6 @@ fn main() {
710
assert_eq!(size_of_val(&[] as &[i32]), 0);
811
assert_eq!(size_of_val(&[1, 2, 3] as &[i32]), 12);
912
assert_eq!(size_of_val("foobar"), 6);
13+
14+
assert_eq!(unsafe { type_name::<Option<i32>>() }, "core::option::Option<i32>");
1015
}

0 commit comments

Comments
 (0)