Skip to content

Commit bdd23bf

Browse files
committed
tcx.lift_to_global > tcx.global_tcx().lift
1 parent 569ae80 commit bdd23bf

File tree

4 files changed

+15
-19
lines changed

4 files changed

+15
-19
lines changed

src/librustc/mir/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,8 +1151,7 @@ impl<'tcx> TerminatorKind<'tcx> {
11511151
SwitchInt { ref values, switch_ty, .. } => {
11521152
let size = ty::tls::with(|tcx| {
11531153
let param_env = ty::ParamEnv::empty();
1154-
let tcx = tcx.global_tcx();
1155-
let switch_ty = tcx.lift(&switch_ty).unwrap();
1154+
let switch_ty = tcx.lift_to_global(&switch_ty).unwrap();
11561155
tcx.layout_of(param_env.and(switch_ty)).unwrap().size
11571156
});
11581157
values.iter()
@@ -1908,8 +1907,8 @@ pub fn print_miri_value<W: Write>(value: Value, ty: Ty, f: &mut W) -> fmt::Resul
19081907
(Value::Scalar(Scalar::Bits { bits, .. }), &TyUint(ui)) => write!(f, "{:?}{}", bits, ui),
19091908
(Value::Scalar(Scalar::Bits { bits, .. }), &TyInt(i)) => {
19101909
let bit_width = ty::tls::with(|tcx| {
1911-
let ty = tcx.global_tcx().lift(&ty).unwrap();
1912-
tcx.global_tcx().layout_of(ty::ParamEnv::empty().and(ty)).unwrap().size.bits()
1910+
let ty = tcx.lift_to_global(&ty).unwrap();
1911+
tcx.layout_of(ty::ParamEnv::empty().and(ty)).unwrap().size.bits()
19131912
});
19141913
let amt = 128 - bit_width;
19151914
write!(f, "{:?}{}", ((bits as i128) << amt) >> amt, i)

src/librustc/ty/sty.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,8 +1823,8 @@ impl<'tcx> Const<'tcx> {
18231823
bits: u128,
18241824
ty: ParamEnvAnd<'tcx, Ty<'tcx>>,
18251825
) -> &'tcx Self {
1826-
let ty = tcx.global_tcx().lift(&ty).unwrap();
1827-
let size = tcx.global_tcx().layout_of(ty).unwrap_or_else(|e| {
1826+
let ty = tcx.lift_to_global(&ty).unwrap();
1827+
let size = tcx.layout_of(ty).unwrap_or_else(|e| {
18281828
panic!("could not compute layout for {:?}: {:?}", ty, e)
18291829
}).size;
18301830
let amt = 128 - size.bits();
@@ -1857,8 +1857,8 @@ impl<'tcx> Const<'tcx> {
18571857
if self.ty != ty.value {
18581858
return None;
18591859
}
1860-
let ty = tcx.global_tcx().lift(&ty).unwrap();
1861-
let size = tcx.global_tcx().layout_of(ty).ok()?.size;
1860+
let ty = tcx.lift_to_global(&ty).unwrap();
1861+
let size = tcx.layout_of(ty).ok()?.size;
18621862
match self.val {
18631863
ConstVal::Value(val) => val.to_bits(size),
18641864
_ => None,
@@ -1896,8 +1896,8 @@ impl<'tcx> Const<'tcx> {
18961896
ty: ParamEnvAnd<'tcx, Ty<'tcx>>,
18971897
) -> Option<u128> {
18981898
assert_eq!(self.ty, ty.value);
1899-
let ty = tcx.global_tcx().lift(&ty).unwrap();
1900-
let size = tcx.global_tcx().layout_of(ty).ok()?.size;
1899+
let ty = tcx.lift_to_global(&ty).unwrap();
1900+
let size = tcx.layout_of(ty).ok()?.size;
19011901
match self.val {
19021902
ConstVal::Value(val) => val.to_bits(size),
19031903
_ => None,

src/librustc_mir/build/expr/as_rvalue.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
374374

375375
// Helper to get a `-1` value of the appropriate type
376376
fn neg_1_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> {
377-
let gcx = self.hir.tcx().global_tcx();
378-
let param_ty = ty::ParamEnv::empty().and(gcx.lift(&ty).unwrap());
379-
let bits = gcx.layout_of(param_ty).unwrap().size.bits();
377+
let param_ty = ty::ParamEnv::empty().and(self.hir.tcx().lift_to_global(&ty).unwrap());
378+
let bits = self.hir.tcx().layout_of(param_ty).unwrap().size.bits();
380379
let n = (!0u128) >> (128 - bits);
381380
let literal = Literal::Value {
382381
value: ty::Const::from_bits(self.hir.tcx(), n, param_ty)
@@ -387,10 +386,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
387386

388387
// Helper to get the minimum value of the appropriate type
389388
fn minval_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> {
390-
let gcx = self.hir.tcx().global_tcx();
391389
assert!(ty.is_signed());
392-
let param_ty = ty::ParamEnv::empty().and(gcx.lift(&ty).unwrap());
393-
let bits = gcx.layout_of(param_ty).unwrap().size.bits();
390+
let param_ty = ty::ParamEnv::empty().and(self.hir.tcx().lift_to_global(&ty).unwrap());
391+
let bits = self.hir.tcx().layout_of(param_ty).unwrap().size.bits();
394392
let n = 1 << (bits - 1);
395393
let literal = Literal::Value {
396394
value: ty::Const::from_bits(self.hir.tcx(), n, param_ty)

src/librustc_mir/hair/cx/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,8 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
156156
};
157157

158158
let trunc = |n| {
159-
let gcx = self.tcx.global_tcx();
160-
let param_ty = self.param_env.and(gcx.lift(&ty).unwrap());
161-
let bit_width = gcx.layout_of(param_ty).unwrap().size.bits();
159+
let param_ty = self.param_env.and(self.tcx.lift_to_global(&ty).unwrap());
160+
let bit_width = self.tcx.layout_of(param_ty).unwrap().size.bits();
162161
trace!("trunc {} with size {} and amt {}", n, bit_width, 128 - bit_width);
163162
let amt = 128 - bit_width;
164163
let result = (n << amt) >> amt;

0 commit comments

Comments
 (0)