From 8a586eb6cb7609a055273b2e5fd105157fd2c124 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 6 Jan 2019 15:27:20 +0100 Subject: [PATCH] Rustup to rustc 1.33.0-nightly (68fe5182c 2019-01-05) --- src/constant.rs | 19 +++++++++---------- src/intrinsics.rs | 5 +++++ src/lib.rs | 2 +- src/vtable.rs | 15 ++++++++++----- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 56900a4fa020..a4177552cb3a 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -3,7 +3,7 @@ use std::borrow::Cow; use rustc::mir::interpret::{ read_target_uint, AllocId, AllocKind, Allocation, ConstValue, EvalResult, GlobalId, Scalar, }; -use rustc::ty::Const; +use rustc::ty::{Const, LazyConst}; use rustc_mir::interpret::{ EvalContext, MPlaceTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, StackPopCleanup, }; @@ -61,7 +61,6 @@ pub fn trans_promoted<'a, 'tcx: 'a>( })) .unwrap(); - let const_ = force_eval_const(fx, const_); trans_const_place(fx, const_) } @@ -76,10 +75,10 @@ pub fn trans_constant<'a, 'tcx: 'a>( pub fn force_eval_const<'a, 'tcx: 'a>( fx: &FunctionCx<'a, 'tcx, impl Backend>, - const_: &'tcx Const<'tcx>, -) -> &'tcx Const<'tcx> { - match const_.val { - ConstValue::Unevaluated(def_id, ref substs) => { + const_: &'tcx LazyConst<'tcx>, +) -> Const<'tcx> { + match *const_ { + LazyConst::Unevaluated(def_id, ref substs) => { let param_env = ParamEnv::reveal_all(); let instance = Instance::resolve(fx.tcx, param_env, def_id, substs).unwrap(); let cid = GlobalId { @@ -88,13 +87,13 @@ pub fn force_eval_const<'a, 'tcx: 'a>( }; fx.tcx.const_eval(param_env.and(cid)).unwrap() } - _ => const_, + LazyConst::Evaluated(const_) => const_, } } fn trans_const_value<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - const_: &'tcx Const<'tcx>, + const_: Const<'tcx>, ) -> CValue<'tcx> { let ty = fx.monomorphize(&const_.ty); let layout = fx.layout_of(ty); @@ -124,7 +123,7 @@ fn trans_const_value<'a, 'tcx: 'a>( fn trans_const_place<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - const_: &'tcx Const<'tcx>, + const_: Const<'tcx>, ) -> CPlace<'tcx> { // Adapted from https://github.com/rust-lang/rust/pull/53671/files#diff-e0b58bb6712edaa8595ad7237542c958L551 let result = || -> EvalResult<'tcx, &'tcx Allocation> { @@ -146,7 +145,7 @@ fn trans_const_place<'a, 'tcx: 'a>( span: DUMMY_SP, ty: const_.ty, user_ty: None, - literal: const_, + literal: fx.tcx.intern_lazy_const(LazyConst::Evaluated(const_)), })), None, )?; diff --git a/src/intrinsics.rs b/src/intrinsics.rs index a487012f96a5..2b0c44c2f6f5 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -352,6 +352,11 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let needs_drop = CValue::const_val(fx, fx.tcx.types.bool, needs_drop); ret.write_cvalue(fx, needs_drop); }; + panic_if_uninhabited, () { + if fx.layout_of(T).abi.is_uninhabited() { + crate::trap::trap_panic(&mut fx.bcx); + } + }; _ if intrinsic.starts_with("atomic_fence"), () {}; _ if intrinsic.starts_with("atomic_singlethreadfence"), () {}; diff --git a/src/lib.rs b/src/lib.rs index a9a6895d46b9..7df9b6ae42ee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -103,7 +103,7 @@ mod prelude { pub struct Caches<'tcx> { pub context: Context, - pub vtables: HashMap<(Ty<'tcx>, ty::PolyExistentialTraitRef<'tcx>), DataId>, + pub vtables: HashMap<(Ty<'tcx>, Option>), DataId>, } impl<'tcx> Default for Caches<'tcx> { diff --git a/src/vtable.rs b/src/vtable.rs index 2944330fbe60..61455c6a70a0 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -51,7 +51,7 @@ pub fn get_ptr_and_method_ref<'a, 'tcx: 'a>( pub fn get_vtable<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>, - trait_ref: ty::PolyExistentialTraitRef<'tcx>, + trait_ref: Option>, ) -> Value { let data_id = if let Some(data_id) = fx.caches.vtables.get(&(ty, trait_ref)) { *data_id @@ -68,7 +68,7 @@ pub fn get_vtable<'a, 'tcx: 'a>( fn build_vtable<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>, - trait_ref: ty::PolyExistentialTraitRef<'tcx>, + trait_ref: Option>, ) -> DataId { let tcx = fx.tcx; let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; @@ -81,9 +81,14 @@ fn build_vtable<'a, 'tcx: 'a>( let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None]; - let trait_ref = trait_ref.with_self_ty(tcx, ty); - let methods = tcx.vtable_methods(trait_ref); - let methods = methods.iter().cloned().map(|opt_mth| { + let methods_root; + let methods = if let Some(trait_ref) = trait_ref { + methods_root = tcx.vtable_methods(trait_ref.with_self_ty(tcx, ty)); + methods_root.iter() + } else { + (&[]).iter() + }; + let methods = methods.cloned().map(|opt_mth| { opt_mth.map_or(None, |(def_id, substs)| { Some(import_function( tcx,