Skip to content

Commit c1bf153

Browse files
committed
Rustup to rustc 1.43.0-nightly (8aa9d2014 2020-02-21)
1 parent 2714068 commit c1bf153

File tree

5 files changed

+18
-44
lines changed

5 files changed

+18
-44
lines changed

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2020-02-14
1+
nightly-2020-02-22

src/base.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,8 @@ fn codegen_array_len<'tcx>(
632632
) -> Value {
633633
match place.layout().ty.kind {
634634
ty::Array(_elem_ty, len) => {
635-
let len = crate::constant::force_eval_const(fx, len)
635+
let len = fx.monomorphize(&len)
636+
.eval(fx.tcx, ParamEnv::reveal_all())
636637
.eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64;
637638
fx.bcx.ins().iconst(fx.pointer_type, len)
638639
}

src/common.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,10 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> {
374374
caller.line as u32,
375375
caller.col_display as u32 + 1,
376376
));
377-
crate::constant::trans_const_value(self, const_loc)
377+
crate::constant::trans_const_value(
378+
self,
379+
ty::Const::from_value(self.tcx, const_loc, self.tcx.caller_location_ty()),
380+
)
378381
}
379382

380383
pub fn triple(&self) -> &target_lexicon::Triple {

src/constant.rs

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -69,47 +69,12 @@ pub fn trans_constant<'tcx>(
6969
fx.layout_of(fx.monomorphize(&constant.literal.ty)),
7070
).to_cvalue(fx);
7171
}
72-
ConstKind::Unevaluated(def_id, ref substs, promoted) => {
73-
let substs = fx.monomorphize(substs);
74-
fx.tcx.const_eval_resolve(
75-
ParamEnv::reveal_all(),
76-
def_id,
77-
substs,
78-
promoted,
79-
None, // FIXME use correct span
80-
).unwrap_or_else(|_| {
81-
fx.tcx.sess.abort_if_errors();
82-
unreachable!();
83-
})
84-
}
85-
_ => fx.monomorphize(&constant.literal),
72+
_ => fx.monomorphize(&constant.literal).eval(fx.tcx, ParamEnv::reveal_all()),
8673
};
8774

8875
trans_const_value(fx, const_)
8976
}
9077

91-
pub fn force_eval_const<'tcx>(
92-
fx: &FunctionCx<'_, 'tcx, impl Backend>,
93-
const_: &'tcx Const,
94-
) -> &'tcx Const<'tcx> {
95-
match const_.val {
96-
ConstKind::Unevaluated(def_id, ref substs, promoted) => {
97-
let substs = fx.monomorphize(substs);
98-
fx.tcx.const_eval_resolve(
99-
ParamEnv::reveal_all(),
100-
def_id,
101-
substs,
102-
promoted,
103-
None, // FIXME pass correct span
104-
).unwrap_or_else(|_| {
105-
fx.tcx.sess.abort_if_errors();
106-
unreachable!();
107-
})
108-
}
109-
_ => fx.monomorphize(&const_),
110-
}
111-
}
112-
11378
pub fn trans_const_value<'tcx>(
11479
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
11580
const_: &'tcx Const<'tcx>,
@@ -338,8 +303,8 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module<impl Backend>, cx: &mu
338303

339304
let const_ = tcx.const_eval_poly(def_id).unwrap();
340305

341-
let alloc = match const_.val {
342-
ConstKind::Value(ConstValue::ByRef { alloc, offset }) if offset.bytes() == 0 => alloc,
306+
let alloc = match const_ {
307+
ConstValue::ByRef { alloc, offset } if offset.bytes() == 0 => alloc,
343308
_ => bug!("static const eval returned {:#?}", const_),
344309
};
345310

@@ -537,7 +502,9 @@ pub fn mir_operand_get_const_val<'tcx>(
537502
operand: &Operand<'tcx>,
538503
) -> Option<&'tcx Const<'tcx>> {
539504
match operand {
540-
Operand::Copy(_) | Operand::Move(_) => return None,
541-
Operand::Constant(const_) => return Some(force_eval_const(fx, const_.literal)),
505+
Operand::Copy(_) | Operand::Move(_) => None,
506+
Operand::Constant(const_) => {
507+
Some(fx.monomorphize(&const_.literal).eval(fx.tcx, ParamEnv::reveal_all()))
508+
}
542509
}
543510
}

src/intrinsics/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,10 @@ pub fn codegen_intrinsic_call<'tcx>(
835835
size_of | pref_align_of | min_align_of | needs_drop | type_id | type_name, () {
836836
let const_val =
837837
fx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap();
838-
let val = crate::constant::trans_const_value(fx, const_val);
838+
let val = crate::constant::trans_const_value(
839+
fx,
840+
ty::Const::from_value(fx.tcx, const_val, ret.layout().ty),
841+
);
839842
ret.write_cvalue(fx, val);
840843
};
841844

0 commit comments

Comments
 (0)