]> git.lizzy.rs Git - rust.git/commitdiff
Rustup to rustc 1.33.0-nightly (68fe5182c 2019-01-05)
authorbjorn3 <bjorn3@users.noreply.github.com>
Sun, 6 Jan 2019 14:27:20 +0000 (15:27 +0100)
committerbjorn3 <bjorn3@users.noreply.github.com>
Sun, 6 Jan 2019 14:27:20 +0000 (15:27 +0100)
src/constant.rs
src/intrinsics.rs
src/lib.rs
src/vtable.rs

index 56900a4fa020cd78679df568509a37176c9136f1..a4177552cb3a085f045e64590c8dd723304a65d3 100644 (file)
@@ -3,7 +3,7 @@
 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,
         )?;
index a487012f96a550e8c337a20725ec1d5e10529b9c..2b0c44c2f6f533c2404d3491502ed1ded1f46297 100644 (file)
@@ -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, <T> () {
+            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"), () {};
index a9a6895d46b946a63614fb055d6714ea50c68d86..7df9b6ae42eeb94423cf27bbea555b0b309f88d6 100644 (file)
@@ -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<ty::PolyExistentialTraitRef<'tcx>>), DataId>,
 }
 
 impl<'tcx> Default for Caches<'tcx> {
index 2944330fbe606a66563990486ca9bb37696468bf..61455c6a70a09d1df73dc4376702025587bf43b2 100644 (file)
@@ -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<ty::PolyExistentialTraitRef<'tcx>>,
 ) -> 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<ty::PolyExistentialTraitRef<'tcx>>,
 ) -> 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,