]> git.lizzy.rs Git - rust.git/commitdiff
Bad tags are unreachable
authorvarkor <github@varkor.com>
Fri, 23 Feb 2018 22:15:07 +0000 (22:15 +0000)
committervarkor <github@varkor.com>
Fri, 23 Feb 2018 22:15:07 +0000 (22:15 +0000)
src/librustc/ty/subst.rs

index 3eb859679dae20d4f63f0df09c985df0be96661e..cf6a1e354d3cda0f5e7f4a70fe72d868cb8c3ee3 100644 (file)
@@ -18,6 +18,7 @@
 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()
+            }
         }
     }
 }