Created
July 29, 2013 19:13
-
-
Save luqmana/6106904 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn find_fn(ccx: @mut CrateContext, fn_id: ast::node_id) -> Option<codemap::span> { | |
match ccx.tcx.def_map.find(&fn_id) { | |
Some(&ast::def_fn(def_id, _)) => { | |
if ast_util::is_local(def_id) { | |
match ccx.tcx.items.find(&def_id.node) { | |
Some(&ast_map::node_item(item, _)) => { | |
match item.node { | |
ast::item_fn(*) => Some(item.span), | |
_ => None | |
} | |
} | |
None => None | |
} | |
} else { | |
let search = csearch::maybe_get_item_ast( | |
ccx.tcx, def_id, | |
|a, b, c, d| astencode::decode_inlined_item(a, b, ccx.maps(), c.clone(), d)); | |
match search { | |
csearch::found(ast::ii_item(item)) => { | |
match item.node { | |
ast::item_fn(*) => Some(item.span), | |
_ => None | |
} | |
} | |
_ => None | |
} | |
} | |
} | |
_ => None | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment