Skip to content

Commit

Permalink
save-analysis: fix ICE on partially resolved path
Browse files Browse the repository at this point in the history
Occurs when we produce save-analysis before type checking is complete (due to errors).
  • Loading branch information
nrc committed Nov 22, 2016
1 parent 4bc9290 commit 3295afa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/librustc/hir/def.rs
Expand Up @@ -85,10 +85,15 @@ impl 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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_save_analysis/lib.rs
Expand Up @@ -497,7 +497,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
}

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 {
Expand Down

0 comments on commit 3295afa

Please sign in to comment.