There's a tcx in scope, don't use the tls one

This commit is contained in:
Oliver Scherer 2019-04-02 14:23:23 +02:00
parent 8d4f4cdada
commit a92d97ee70
1 changed files with 11 additions and 15 deletions

View File

@ -1557,31 +1557,27 @@ define_print_and_forward_display! {
(ConstValue::Scalar(Scalar::Bits { bits, ..}), ty::Uint(ui)) => (ConstValue::Scalar(Scalar::Bits { bits, ..}), ty::Uint(ui)) =>
p!(write("{}{}", bits, ui)), p!(write("{}{}", bits, ui)),
(ConstValue::Scalar(Scalar::Bits { bits, ..}), ty::Int(i)) => { (ConstValue::Scalar(Scalar::Bits { bits, ..}), ty::Int(i)) => {
let size = ty::tls::with(|tcx| { let ty = cx.tcx().lift_to_global(&self.ty).unwrap();
let ty = tcx.lift_to_global(&self.ty).unwrap(); let size = cx.tcx().layout_of(ty::ParamEnv::empty().and(ty))
tcx.layout_of(ty::ParamEnv::empty().and(ty)) .unwrap()
.unwrap() .size;
.size
});
p!(write("{}{}", sign_extend(bits, size) as i128, i)) p!(write("{}{}", sign_extend(bits, size) as i128, i))
}, },
(ConstValue::Scalar(Scalar::Bits { bits, ..}), ty::Char) (ConstValue::Scalar(Scalar::Bits { bits, ..}), ty::Char)
=> p!(write("{}", ::std::char::from_u32(bits as u32).unwrap())), => p!(write("{}", ::std::char::from_u32(bits as u32).unwrap())),
(_, ty::FnDef(did, _)) => p!(write("{}", ty::tls::with(|tcx| tcx.def_path_str(*did)))), (_, ty::FnDef(did, _)) => p!(write("{}", cx.tcx().def_path_str(*did))),
(ConstValue::Slice(_, 0), ty::Ref(_, &ty::TyS { sty: ty::Str, .. }, _)) => (ConstValue::Slice(_, 0), ty::Ref(_, &ty::TyS { sty: ty::Str, .. }, _)) =>
p!(write("\"\"")), p!(write("\"\"")),
( (
ConstValue::Slice(Scalar::Ptr(ptr), len), ConstValue::Slice(Scalar::Ptr(ptr), len),
ty::Ref(_, &ty::TyS { sty: ty::Str, .. }, _), ty::Ref(_, &ty::TyS { sty: ty::Str, .. }, _),
) => { ) => {
ty::tls::with(|tcx| { let alloc = cx.tcx().alloc_map.lock().unwrap_memory(ptr.alloc_id);
let alloc = tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id); assert_eq!(len as usize as u64, len);
assert_eq!(len as usize as u64, len); let slice =
let slice = &alloc.bytes[(ptr.offset.bytes() as usize)..][..(len as usize)];
&alloc.bytes[(ptr.offset.bytes() as usize)..][..(len as usize)]; let s = ::std::str::from_utf8(slice).expect("non utf8 str from miri");
let s = ::std::str::from_utf8(slice).expect("non utf8 str from miri"); p!(write("{:?}", s))
Ok(p!(write("{:?}", s)))
})?;
}, },
_ => p!(write("{:?} : ", self.val), print(self.ty)), _ => p!(write("{:?} : ", self.val), print(self.ty)),
} }