Skip to content

Commit b1f86fb

Browse files
committed
Inspect def locally instead of using a method
1 parent 68312e3 commit b1f86fb

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/librustc/hir/def.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,10 @@ impl PathResolution {
8585

8686
/// Get the definition, if fully resolved, otherwise panic.
8787
pub fn full_def(&self) -> Def {
88-
self.maybe_full_def().unwrap_or_else(|| bug!("path not fully resolved: {:?}", self))
89-
}
90-
91-
pub fn maybe_full_def(&self) -> Option<Def> {
92-
if self.depth == 0 {
93-
Some(self.base_def)
94-
} else {
95-
None
88+
if self.depth != 0 {
89+
bug!("path not fully resolved: {:?}", self);
9690
}
91+
self.base_def
9792
}
9893

9994
pub fn kind_name(&self) -> &'static str {

src/librustc_save_analysis/lib.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,12 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
497497
}
498498

499499
pub fn get_path_data(&self, id: NodeId, path: &ast::Path) -> Option<Data> {
500-
let def = option_try!(self.tcx.expect_resolution(id).maybe_full_def());
500+
let resolution = self.tcx.expect_resolution(id);
501+
if resolution.depth != 0 {
502+
return None;
503+
}
504+
let def = resolution.base_def;
505+
501506
let sub_span = self.span_utils.span_for_last_ident(path.span);
502507
filter!(self.span_utils, sub_span, path.span, None);
503508
match def {

0 commit comments

Comments
 (0)