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.
This commit is contained in:
parent
f1730d136a
commit
1ceb81b345
3 changed files with 7 additions and 10 deletions
|
|
@ -1 +1 @@
|
|||
021a5033098ff0e3f7126acc7ac35149d325f16d
|
||||
7cdaffd7962c4aae0cadd82baa241901b03f9458
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use rustc::ty;
|
|||
|
||||
use crate::{
|
||||
PlaceTy, OpTy, ImmTy, Immediate, Scalar, ScalarMaybeUndef, Tag,
|
||||
OperatorEvalContextExt, MiriMemoryKind,
|
||||
OperatorEvalContextExt
|
||||
};
|
||||
|
||||
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,
|
|||
)?;
|
||||
}
|
||||
|
||||
"type_name" => {
|
||||
let ty = substs.type_at(0);
|
||||
let ty_name = ty.to_string();
|
||||
let ptr = this.memory_mut().allocate_static_bytes(ty_name.as_bytes(), MiriMemoryKind::Static.into());
|
||||
let value = Immediate::new_slice(Scalar::Ptr(ptr), ty_name.len() as u64, this);
|
||||
this.write_immediate(value, dest)?;
|
||||
}
|
||||
|
||||
"unchecked_div" => {
|
||||
let l = this.read_immediate(args[0])?;
|
||||
let r = this.read_immediate(args[1])?;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
#![feature(core_intrinsics)]
|
||||
|
||||
use std::intrinsics::type_name;
|
||||
use std::mem::{size_of, size_of_val};
|
||||
|
||||
fn main() {
|
||||
|
|
@ -7,4 +10,6 @@ fn main() {
|
|||
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>");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue