]> git.lizzy.rs Git - rust.git/commitdiff
save-analysis: fix ICE on partially resolved path
authorNick Cameron <ncameron@mozilla.com>
Mon, 21 Nov 2016 05:11:36 +0000 (18:11 +1300)
committerNick Cameron <ncameron@mozilla.com>
Tue, 22 Nov 2016 22:53:27 +0000 (11:53 +1300)
Occurs when we produce save-analysis before type checking is complete (due to errors).

src/librustc/hir/def.rs
src/librustc_save_analysis/lib.rs

index feefc43f4013e682af3628f86cb1353ae81f0397..ce04a7c897a18fcac20d556d97a815765abde2c8 100644 (file)
@@ -85,10 +85,15 @@ pub fn new(def: Def) -> PathResolution {
 
     /// Get the definition, if fully resolved, otherwise panic.
     pub fn full_def(&self) -> Def {
-        if self.depth != 0 {
-            bug!("path not fully resolved: {:?}", self);
+        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
         }
-        self.base_def
     }
 
     pub fn kind_name(&self) -> &'static str {
index 778f0184141651061552c44dbe7e0d655d84962f..4c59f5e8a83cbc22a166e0d39134b3a4f95730ad 100644 (file)
@@ -497,7 +497,7 @@ pub fn get_expr_data(&self, expr: &ast::Expr) -> Option<Data> {
     }
 
     pub fn get_path_data(&self, id: NodeId, path: &ast::Path) -> Option<Data> {
-        let def = self.tcx.expect_def(id);
+        let def = option_try!(self.tcx.expect_resolution(id).maybe_full_def());
         let sub_span = self.span_utils.span_for_last_ident(path.span);
         filter!(self.span_utils, sub_span, path.span, None);
         match def {