Skip to content

Commit f2b9686

Browse files
committed
Bad tags are unreachable
1 parent 8b2037c commit f2b9686

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/librustc/ty/subst.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use serialize::{self, Encodable, Encoder, Decodable, Decoder};
1818
use syntax_pos::{Span, DUMMY_SP};
1919
use rustc_data_structures::accumulate_vec::AccumulateVec;
2020

21+
use core::intrinsics;
2122
use core::nonzero::NonZero;
2223
use std::fmt;
2324
use std::iter;
@@ -84,14 +85,12 @@ impl<'tcx> Kind<'tcx> {
8485
#[inline]
8586
pub fn unpack(self) -> UnpackedKind<'tcx> {
8687
let ptr = self.ptr.get();
87-
match ptr & TAG_MASK {
88-
REGION_TAG => unsafe {
89-
UnpackedKind::Lifetime(&*((ptr & !TAG_MASK) as *const _))
90-
},
91-
TYPE_TAG => unsafe {
92-
UnpackedKind::Type(&*((ptr & !TAG_MASK) as *const _))
93-
},
94-
_ => bug!("packed kind has invalid tag")
88+
unsafe {
89+
match ptr & TAG_MASK {
90+
REGION_TAG => UnpackedKind::Lifetime(&*((ptr & !TAG_MASK) as *const _)),
91+
TYPE_TAG => UnpackedKind::Type(&*((ptr & !TAG_MASK) as *const _)),
92+
_ => intrinsics::unreachable()
93+
}
9594
}
9695
}
9796
}

0 commit comments

Comments
 (0)