summary refs log tree commit diff
path: root/src/librustc_codegen_llvm
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-05-16 21:26:50 +0100
committervarkor <github@varkor.com>2018-05-17 18:15:24 +0100
commit05067cf99e21bcb8fd5dce745d09865d1a91b189 (patch)
tree86b7bde652e3e1ff7c76e22958c28ad28f456dda /src/librustc_codegen_llvm
parentdbd10f81758381339f98994b8d31814cf5e98707 (diff)
downloadrust-05067cf99e21bcb8fd5dce745d09865d1a91b189.tar.gz
rust-05067cf99e21bcb8fd5dce745d09865d1a91b189.zip
Fix an ICE when attempting to transmute an uninhabited type
Diffstat (limited to 'src/librustc_codegen_llvm')
-rw-r--r--src/librustc_codegen_llvm/mir/block.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/librustc_codegen_llvm/mir/block.rs b/src/librustc_codegen_llvm/mir/block.rs
index 556baeba39e..bc5819791fa 100644
--- a/src/librustc_codegen_llvm/mir/block.rs
+++ b/src/librustc_codegen_llvm/mir/block.rs
@@ -428,9 +428,19 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> {
                 let intrinsic = intrinsic.as_ref().map(|s| &s[..]);
 
                 if intrinsic == Some("transmute") {
-                    let &(ref dest, target) = destination.as_ref().unwrap();
-                    self.codegen_transmute(&bx, &args[0], dest);
-                    funclet_br(self, bx, target);
+                    if let Some(destination_ref) = destination.as_ref() {
+                        let &(ref dest, target) = destination_ref;
+                        self.trans_transmute(&bx, &args[0], dest);
+                        funclet_br(self, bx, target);
+                    } else {
+                        // If we are trying to transmute to an uninhabited type,
+                        // it is likely there is no allotted destination. In fact,
+                        // transmuting to an uninhabited type is UB, which means
+                        // we can do what we like. Here, we declare that transmuting
+                        // into an uninhabited type is impossible, so anything following
+                        // it must be unreachable.
+                        bx.unreachable();
+                    }
                     return;
                 }