Inspect def locally instead of using a method

This commit is contained in:
Nick Cameron 2016-11-24 07:50:22 +13:00
parent 68312e3e20
commit b1f86fb7c3
2 changed files with 9 additions and 9 deletions

View File

@ -85,15 +85,10 @@ impl PathResolution {
/// Get the definition, if fully resolved, otherwise panic.
pub fn full_def(&self) -> Def {
self.maybe_full_def().unwrap_or_else(|| bug!("path not fully resolved: {:?}", self))
}
pub fn maybe_full_def(&self) -> Option<Def> {
if self.depth == 0 {
Some(self.base_def)
} else {
None
if self.depth != 0 {
bug!("path not fully resolved: {:?}", self);
}
self.base_def
}
pub fn kind_name(&self) -> &'static str {

View File

@ -497,7 +497,12 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
}
pub fn get_path_data(&self, id: NodeId, path: &ast::Path) -> Option<Data> {
let def = option_try!(self.tcx.expect_resolution(id).maybe_full_def());
let resolution = self.tcx.expect_resolution(id);
if resolution.depth != 0 {
return None;
}
let def = resolution.base_def;
let sub_span = self.span_utils.span_for_last_ident(path.span);
filter!(self.span_utils, sub_span, path.span, None);
match def {