about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-02-23 22:15:07 +0000
committervarkor <github@varkor.com>2018-02-23 22:15:07 +0000
commitf2b9686134d7e75d4b57d0d0f6cf81d63d638627 (patch)
tree503e308bd00b62485fb65b6ab48a62c7a1850c3a
parent8b2037c6fec88fc02b7f5087f14f25b9476dd42d (diff)
downloadrust-f2b9686134d7e75d4b57d0d0f6cf81d63d638627.tar.gz
rust-f2b9686134d7e75d4b57d0d0f6cf81d63d638627.zip
Bad tags are unreachable
-rw-r--r--src/librustc/ty/subst.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs
index 3eb859679da..cf6a1e354d3 100644
--- a/src/librustc/ty/subst.rs
+++ b/src/librustc/ty/subst.rs
@@ -18,6 +18,7 @@ use serialize::{self, Encodable, Encoder, Decodable, Decoder};
 use syntax_pos::{Span, DUMMY_SP};
 use rustc_data_structures::accumulate_vec::AccumulateVec;
 
+use core::intrinsics;
 use core::nonzero::NonZero;
 use std::fmt;
 use std::iter;
@@ -84,14 +85,12 @@ impl<'tcx> Kind<'tcx> {
     #[inline]
     pub fn unpack(self) -> UnpackedKind<'tcx> {
         let ptr = self.ptr.get();
-        match ptr & TAG_MASK {
-            REGION_TAG => unsafe {
-                UnpackedKind::Lifetime(&*((ptr & !TAG_MASK) as *const _))
-            },
-            TYPE_TAG => unsafe {
-                UnpackedKind::Type(&*((ptr & !TAG_MASK) as *const _))
-            },
-            _ => bug!("packed kind has invalid tag")
+        unsafe {
+            match ptr & TAG_MASK {
+                REGION_TAG => UnpackedKind::Lifetime(&*((ptr & !TAG_MASK) as *const _)),
+                TYPE_TAG => UnpackedKind::Type(&*((ptr & !TAG_MASK) as *const _)),
+                _ => intrinsics::unreachable()
+            }
         }
     }
 }