Skip to content

Commit a92d97e

Browse files
committed
There's a tcx in scope, don't use the tls one
1 parent 8d4f4cd commit a92d97e

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/librustc/ty/print/pretty.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,31 +1557,27 @@ define_print_and_forward_display! {
15571557
(ConstValue::Scalar(Scalar::Bits { bits, ..}), ty::Uint(ui)) =>
15581558
p!(write("{}{}", bits, ui)),
15591559
(ConstValue::Scalar(Scalar::Bits { bits, ..}), ty::Int(i)) => {
1560-
let size = ty::tls::with(|tcx| {
1561-
let ty = tcx.lift_to_global(&self.ty).unwrap();
1562-
tcx.layout_of(ty::ParamEnv::empty().and(ty))
1563-
.unwrap()
1564-
.size
1565-
});
1560+
let ty = cx.tcx().lift_to_global(&self.ty).unwrap();
1561+
let size = cx.tcx().layout_of(ty::ParamEnv::empty().and(ty))
1562+
.unwrap()
1563+
.size;
15661564
p!(write("{}{}", sign_extend(bits, size) as i128, i))
15671565
},
15681566
(ConstValue::Scalar(Scalar::Bits { bits, ..}), ty::Char)
15691567
=> p!(write("{}", ::std::char::from_u32(bits as u32).unwrap())),
1570-
(_, ty::FnDef(did, _)) => p!(write("{}", ty::tls::with(|tcx| tcx.def_path_str(*did)))),
1568+
(_, ty::FnDef(did, _)) => p!(write("{}", cx.tcx().def_path_str(*did))),
15711569
(ConstValue::Slice(_, 0), ty::Ref(_, &ty::TyS { sty: ty::Str, .. }, _)) =>
15721570
p!(write("\"\"")),
15731571
(
15741572
ConstValue::Slice(Scalar::Ptr(ptr), len),
15751573
ty::Ref(_, &ty::TyS { sty: ty::Str, .. }, _),
15761574
) => {
1577-
ty::tls::with(|tcx| {
1578-
let alloc = tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id);
1579-
assert_eq!(len as usize as u64, len);
1580-
let slice =
1581-
&alloc.bytes[(ptr.offset.bytes() as usize)..][..(len as usize)];
1582-
let s = ::std::str::from_utf8(slice).expect("non utf8 str from miri");
1583-
Ok(p!(write("{:?}", s)))
1584-
})?;
1575+
let alloc = cx.tcx().alloc_map.lock().unwrap_memory(ptr.alloc_id);
1576+
assert_eq!(len as usize as u64, len);
1577+
let slice =
1578+
&alloc.bytes[(ptr.offset.bytes() as usize)..][..(len as usize)];
1579+
let s = ::std::str::from_utf8(slice).expect("non utf8 str from miri");
1580+
p!(write("{:?}", s))
15851581
},
15861582
_ => p!(write("{:?} : ", self.val), print(self.ty)),
15871583
}

0 commit comments

Comments
 (0)