Skip to content

Commit

Permalink
librustc: Restrict transmute intrinsicck to just rust-intrinsic fn's.
Browse files Browse the repository at this point in the history
  • Loading branch information
luqmana committed Aug 25, 2014
1 parent 5fb2dfa commit 6ad0346
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/librustc/middle/intrinsicck.rs
Expand Up @@ -73,21 +73,25 @@ struct IntrinsicCheckingVisitor<'a> {

impl<'a> IntrinsicCheckingVisitor<'a> {
fn def_id_is_transmute(&self, def_id: DefId) -> bool {
let intrinsic = match ty::get(ty::lookup_item_type(self.tcx, def_id).ty).sty {
ty::ty_bare_fn(ref bfty) => bfty.abi == RustIntrinsic,
_ => return false
};
if def_id.krate == ast::LOCAL_CRATE {
match self.tcx.map.get(def_id.node) {
NodeForeignItem(ref item) => {
NodeForeignItem(ref item) if intrinsic => {
token::get_ident(item.ident) ==
token::intern_and_get_ident("transmute")
}
_ => false,
}
} else {
match csearch::get_item_path(self.tcx, def_id).last() {
None => false,
Some(ref last) => {
Some(ref last) if intrinsic => {
token::get_name(last.name()) ==
token::intern_and_get_ident("transmute")
}
_ => false,
}
}
}
Expand Down

0 comments on commit 6ad0346

Please sign in to comment.