diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index d5b3070372ba5..00431f86cf588 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -622,9 +622,11 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { Node::Visibility(&Spanned { node: hir::VisibilityKind::Restricted { ref path, .. }, .. }) => path.def, - Node::PathSegment(seg) => match seg.def { - Some(def) => def, - None => HirDef::Err, + Node::PathSegment(seg) => { + match seg.def { + Some(def) if def != HirDef::Err => def, + _ => self.get_path_def(self.tcx.hir().get_parent_node(id)), + } }, Node::Expr(&hir::Expr { node: hir::ExprKind::Struct(ref qpath, ..),