diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2020-02-22 14:20:37 +0100 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2020-02-22 14:20:37 +0100 |
| commit | c1bf153049cd7897b32ba0969f1e9fc5ccdd2b42 (patch) | |
| tree | 3b666f7cc1f7ace55a7712409f17a3b64a4d7789 /src | |
| parent | 2714068b9709e3e1d13a55f6c442afaecbc08d90 (diff) | |
Rustup to rustc 1.43.0-nightly (8aa9d2014 2020-02-21)
Diffstat (limited to 'src')
| -rw-r--r-- | src/base.rs | 3 | ||||
| -rw-r--r-- | src/common.rs | 5 | ||||
| -rw-r--r-- | src/constant.rs | 47 | ||||
| -rw-r--r-- | src/intrinsics/mod.rs | 5 |
4 files changed, 17 insertions, 43 deletions
diff --git a/src/base.rs b/src/base.rs index 1eab45bf3c6..c741d02b8d7 100644 --- a/src/base.rs +++ b/src/base.rs @@ -632,7 +632,8 @@ fn codegen_array_len<'tcx>( ) -> Value { match place.layout().ty.kind { 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; fx.bcx.ins().iconst(fx.pointer_type, len) } diff --git a/src/common.rs b/src/common.rs index 374ad0acee5..d9659f42d6f 100644 --- a/src/common.rs +++ b/src/common.rs @@ -374,7 +374,10 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { caller.line as u32, 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 { diff --git a/src/constant.rs b/src/constant.rs index c0e2770361c..47e949021df 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -69,47 +69,12 @@ pub fn trans_constant<'tcx>( fx.layout_of(fx.monomorphize(&constant.literal.ty)), ).to_cvalue(fx); } - 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 use correct span - ).unwrap_or_else(|_| { - fx.tcx.sess.abort_if_errors(); - unreachable!(); - }) - } - _ => fx.monomorphize(&constant.literal), + _ => fx.monomorphize(&constant.literal).eval(fx.tcx, ParamEnv::reveal_all()), }; 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>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, 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 alloc = match const_.val { - ConstKind::Value(ConstValue::ByRef { alloc, offset }) if offset.bytes() == 0 => alloc, + let alloc = match const_ { + ConstValue::ByRef { alloc, offset } if offset.bytes() == 0 => alloc, _ => bug!("static const eval returned {:#?}", const_), }; @@ -537,7 +502,9 @@ pub fn mir_operand_get_const_val<'tcx>( operand: &Operand<'tcx>, ) -> Option<&'tcx Const<'tcx>> { match operand { - Operand::Copy(_) | Operand::Move(_) => return None, - Operand::Constant(const_) => return Some(force_eval_const(fx, const_.literal)), + Operand::Copy(_) | Operand::Move(_) => None, + Operand::Constant(const_) => { + Some(fx.monomorphize(&const_.literal).eval(fx.tcx, ParamEnv::reveal_all())) + } } } diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index d23d28dccd2..c8f23555952 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -835,7 +835,10 @@ pub fn codegen_intrinsic_call<'tcx>( size_of | pref_align_of | min_align_of | needs_drop | type_id | type_name, () { let const_val = 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); }; |
