about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2016-11-24 07:50:22 +1300
committerNick Cameron <ncameron@mozilla.com>2016-11-24 07:50:22 +1300
commitb1f86fb7c30c6296a9c2e07d3a58795bca8c4cf4 (patch)
tree84b0a5ab6e4a95604418ed2bda110c0e23a6ca6c
parent68312e3e20a881f2bcde20db0c7ee385c0aa27c1 (diff)
downloadrust-b1f86fb7c30c6296a9c2e07d3a58795bca8c4cf4.tar.gz
rust-b1f86fb7c30c6296a9c2e07d3a58795bca8c4cf4.zip
Inspect def locally instead of using a method
-rw-r--r--src/librustc/hir/def.rs11
-rw-r--r--src/librustc_save_analysis/lib.rs7
2 files changed, 9 insertions, 9 deletions
diff --git a/src/librustc/hir/def.rs b/src/librustc/hir/def.rs
index ce04a7c897a..feefc43f401 100644
--- a/src/librustc/hir/def.rs
+++ b/src/librustc/hir/def.rs
@@ -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 {
diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs
index 4c59f5e8a83..a82a51a2e17 100644
--- a/src/librustc_save_analysis/lib.rs
+++ b/src/librustc_save_analysis/lib.rs
@@ -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 {