diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-04-02 14:23:23 +0200 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-05-25 10:07:01 +0200 |
| commit | a92d97ee70e84e3568eb28cf8e01d2ac6a67e12c (patch) | |
| tree | ada0c49b26e5146704e6acc46c83c68ee30fcbfc /src/librustc/ty | |
| parent | 8d4f4cdadafe7c7deca5bc3a2725a380cfe9d01b (diff) | |
| download | rust-a92d97ee70e84e3568eb28cf8e01d2ac6a67e12c.tar.gz rust-a92d97ee70e84e3568eb28cf8e01d2ac6a67e12c.zip | |
There's a tcx in scope, don't use the tls one
Diffstat (limited to 'src/librustc/ty')
| -rw-r--r-- | src/librustc/ty/print/pretty.rs | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index 87be78857e3..81f5c87184e 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -1557,31 +1557,27 @@ define_print_and_forward_display! { (ConstValue::Scalar(Scalar::Bits { bits, ..}), ty::Uint(ui)) => p!(write("{}{}", bits, ui)), (ConstValue::Scalar(Scalar::Bits { bits, ..}), ty::Int(i)) => { - let size = ty::tls::with(|tcx| { - let ty = tcx.lift_to_global(&self.ty).unwrap(); - tcx.layout_of(ty::ParamEnv::empty().and(ty)) - .unwrap() - .size - }); + let ty = cx.tcx().lift_to_global(&self.ty).unwrap(); + let size = cx.tcx().layout_of(ty::ParamEnv::empty().and(ty)) + .unwrap() + .size; p!(write("{}{}", sign_extend(bits, size) as i128, i)) }, (ConstValue::Scalar(Scalar::Bits { bits, ..}), ty::Char) => 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, .. }, _)) => p!(write("\"\"")), ( ConstValue::Slice(Scalar::Ptr(ptr), len), ty::Ref(_, &ty::TyS { sty: ty::Str, .. }, _), ) => { - ty::tls::with(|tcx| { - let alloc = tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id); - assert_eq!(len as usize as u64, len); - let slice = - &alloc.bytes[(ptr.offset.bytes() as usize)..][..(len as usize)]; - let s = ::std::str::from_utf8(slice).expect("non utf8 str from miri"); - Ok(p!(write("{:?}", s))) - })?; + let alloc = cx.tcx().alloc_map.lock().unwrap_memory(ptr.alloc_id); + assert_eq!(len as usize as u64, len); + let slice = + &alloc.bytes[(ptr.offset.bytes() as usize)..][..(len as usize)]; + let s = ::std::str::from_utf8(slice).expect("non utf8 str from miri"); + p!(write("{:?}", s)) }, _ => p!(write("{:?} : ", self.val), print(self.ty)), } |
