Rustup to rustc 1.43.0-nightly (8aa9d2014
2020-02-21)
This commit is contained in:
parent
2714068b97
commit
c1bf153049
5 changed files with 18 additions and 44 deletions
|
@ -1 +1 @@
|
||||||
nightly-2020-02-14
|
nightly-2020-02-22
|
||||||
|
|
|
@ -632,7 +632,8 @@ fn codegen_array_len<'tcx>(
|
||||||
) -> Value {
|
) -> Value {
|
||||||
match place.layout().ty.kind {
|
match place.layout().ty.kind {
|
||||||
ty::Array(_elem_ty, len) => {
|
ty::Array(_elem_ty, len) => {
|
||||||
let len = crate::constant::force_eval_const(fx, len)
|
let len = fx.monomorphize(&len)
|
||||||
|
.eval(fx.tcx, ParamEnv::reveal_all())
|
||||||
.eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64;
|
.eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64;
|
||||||
fx.bcx.ins().iconst(fx.pointer_type, len)
|
fx.bcx.ins().iconst(fx.pointer_type, len)
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,7 +374,10 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> {
|
||||||
caller.line as u32,
|
caller.line as u32,
|
||||||
caller.col_display as u32 + 1,
|
caller.col_display as u32 + 1,
|
||||||
));
|
));
|
||||||
crate::constant::trans_const_value(self, const_loc)
|
crate::constant::trans_const_value(
|
||||||
|
self,
|
||||||
|
ty::Const::from_value(self.tcx, const_loc, self.tcx.caller_location_ty()),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn triple(&self) -> &target_lexicon::Triple {
|
pub fn triple(&self) -> &target_lexicon::Triple {
|
||||||
|
|
|
@ -69,47 +69,12 @@ pub fn trans_constant<'tcx>(
|
||||||
fx.layout_of(fx.monomorphize(&constant.literal.ty)),
|
fx.layout_of(fx.monomorphize(&constant.literal.ty)),
|
||||||
).to_cvalue(fx);
|
).to_cvalue(fx);
|
||||||
}
|
}
|
||||||
ConstKind::Unevaluated(def_id, ref substs, promoted) => {
|
_ => fx.monomorphize(&constant.literal).eval(fx.tcx, ParamEnv::reveal_all()),
|
||||||
let substs = fx.monomorphize(substs);
|
|
||||||
fx.tcx.const_eval_resolve(
|
|
||||||
ParamEnv::reveal_all(),
|
|
||||||
def_id,
|
|
||||||
substs,
|
|
||||||
promoted,
|
|
||||||
None, // FIXME use correct span
|
|
||||||
).unwrap_or_else(|_| {
|
|
||||||
fx.tcx.sess.abort_if_errors();
|
|
||||||
unreachable!();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
_ => fx.monomorphize(&constant.literal),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
trans_const_value(fx, const_)
|
trans_const_value(fx, const_)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn force_eval_const<'tcx>(
|
|
||||||
fx: &FunctionCx<'_, 'tcx, impl Backend>,
|
|
||||||
const_: &'tcx Const,
|
|
||||||
) -> &'tcx Const<'tcx> {
|
|
||||||
match const_.val {
|
|
||||||
ConstKind::Unevaluated(def_id, ref substs, promoted) => {
|
|
||||||
let substs = fx.monomorphize(substs);
|
|
||||||
fx.tcx.const_eval_resolve(
|
|
||||||
ParamEnv::reveal_all(),
|
|
||||||
def_id,
|
|
||||||
substs,
|
|
||||||
promoted,
|
|
||||||
None, // FIXME pass correct span
|
|
||||||
).unwrap_or_else(|_| {
|
|
||||||
fx.tcx.sess.abort_if_errors();
|
|
||||||
unreachable!();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
_ => fx.monomorphize(&const_),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn trans_const_value<'tcx>(
|
pub fn trans_const_value<'tcx>(
|
||||||
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
|
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
|
||||||
const_: &'tcx Const<'tcx>,
|
const_: &'tcx Const<'tcx>,
|
||||||
|
@ -338,8 +303,8 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module<impl Backend>, cx: &mu
|
||||||
|
|
||||||
let const_ = tcx.const_eval_poly(def_id).unwrap();
|
let const_ = tcx.const_eval_poly(def_id).unwrap();
|
||||||
|
|
||||||
let alloc = match const_.val {
|
let alloc = match const_ {
|
||||||
ConstKind::Value(ConstValue::ByRef { alloc, offset }) if offset.bytes() == 0 => alloc,
|
ConstValue::ByRef { alloc, offset } if offset.bytes() == 0 => alloc,
|
||||||
_ => bug!("static const eval returned {:#?}", const_),
|
_ => bug!("static const eval returned {:#?}", const_),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -537,7 +502,9 @@ pub fn mir_operand_get_const_val<'tcx>(
|
||||||
operand: &Operand<'tcx>,
|
operand: &Operand<'tcx>,
|
||||||
) -> Option<&'tcx Const<'tcx>> {
|
) -> Option<&'tcx Const<'tcx>> {
|
||||||
match operand {
|
match operand {
|
||||||
Operand::Copy(_) | Operand::Move(_) => return None,
|
Operand::Copy(_) | Operand::Move(_) => None,
|
||||||
Operand::Constant(const_) => return Some(force_eval_const(fx, const_.literal)),
|
Operand::Constant(const_) => {
|
||||||
|
Some(fx.monomorphize(&const_.literal).eval(fx.tcx, ParamEnv::reveal_all()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -835,7 +835,10 @@ pub fn codegen_intrinsic_call<'tcx>(
|
||||||
size_of | pref_align_of | min_align_of | needs_drop | type_id | type_name, () {
|
size_of | pref_align_of | min_align_of | needs_drop | type_id | type_name, () {
|
||||||
let const_val =
|
let const_val =
|
||||||
fx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap();
|
fx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap();
|
||||||
let val = crate::constant::trans_const_value(fx, const_val);
|
let val = crate::constant::trans_const_value(
|
||||||
|
fx,
|
||||||
|
ty::Const::from_value(fx.tcx, const_val, ret.layout().ty),
|
||||||
|
);
|
||||||
ret.write_cvalue(fx, val);
|
ret.write_cvalue(fx, val);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue