Skip to content

Commit

Permalink
Bad tags are unreachable
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Feb 23, 2018
1 parent 8b2037c commit f2b9686
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/librustc/ty/subst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
}
}
}
}
Expand Down

0 comments on commit f2b9686

Please sign in to comment.