about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2019-08-10 13:08:47 +0200
committerRalf Jung <post@ralfj.de>2019-08-10 13:09:35 +0200
commit03e95ae4127db1b0ae465e8b58383744b7184a70 (patch)
tree683ead42c5b7cbe8415468bf910eef856193f322 /src
parentd19a359444295bab01de7ff44a9d72302e573bc9 (diff)
downloadrust-03e95ae4127db1b0ae465e8b58383744b7184a70.tar.gz
rust-03e95ae4127db1b0ae465e8b58383744b7184a70.zip
Miri shouldn't look at types
Diffstat (limited to 'src')
-rw-r--r--src/librustc_mir/interpret/eval_context.rs10
-rw-r--r--src/librustc_mir/interpret/terminator.rs8
2 files changed, 12 insertions, 6 deletions
diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs
index 1f23d8c017c..6f4227ed34c 100644
--- a/src/librustc_mir/interpret/eval_context.rs
+++ b/src/librustc_mir/interpret/eval_context.rs
@@ -385,15 +385,19 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
         local: mir::Local,
         layout: Option<TyLayout<'tcx>>,
     ) -> InterpResult<'tcx, TyLayout<'tcx>> {
-        match frame.locals[local].layout.get() {
+        // `const_prop` runs into this with an invalid (empty) frame, so we
+        // have to support that case (mostly by skipping all caching).
+        match frame.locals.get(local).and_then(|state| state.layout.get()) {
             None => {
                 let layout = crate::interpret::operand::from_known_layout(layout, || {
                     let local_ty = frame.body.local_decls[local].ty;
                     let local_ty = self.monomorphize_with_substs(local_ty, frame.instance.substs)?;
                     self.layout_of(local_ty)
                 })?;
-                // Layouts of locals are requested a lot, so we cache them.
-                frame.locals[local].layout.set(Some(layout));
+                if let Some(state) = frame.locals.get(local) {
+                    // Layouts of locals are requested a lot, so we cache them.
+                    state.layout.set(Some(layout));
+                }
                 Ok(layout)
             }
             Some(layout) => Ok(layout),
diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs
index a0c6fb026dd..1d6b48e9da4 100644
--- a/src/librustc_mir/interpret/terminator.rs
+++ b/src/librustc_mir/interpret/terminator.rs
@@ -405,9 +405,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
                         }
                     } else {
                         let local = mir::RETURN_PLACE;
-                        let ty = self.frame().body.local_decls[local].ty;
-                        if !self.tcx.is_ty_uninhabited_from_any_module(ty) {
-                            throw_unsup!(FunctionRetMismatch(self.tcx.types.never, ty))
+                        let callee_layout = self.layout_of_local(self.frame(), local, None)?;
+                        if !callee_layout.abi.is_uninhabited() {
+                            throw_unsup!(FunctionRetMismatch(
+                                self.tcx.types.never, callee_layout.ty
+                            ))
                         }
                     }
                     Ok(())