Skip to content

Commit 39852ca

Browse files
committedNov 19, 2018
Auto merge of rust-lang#56060 - nrc:save-path-fallback, r=zackmdavis
save-analysis: fallback to using path id r? @eddyb

File tree

1 file changed

+17
-4
lines changed
  • src/librustc_save_analysis

1 file changed

+17
-4
lines changed
 

‎src/librustc_save_analysis/lib.rs

+17-4
Original file line numberDiff line numberDiff line change
@@ -688,11 +688,24 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
688688
}
689689
}
690690

691-
pub fn get_path_data(&self, _id: NodeId, path: &ast::Path) -> Option<Ref> {
692-
path.segments.last().and_then(|seg| self.get_path_segment_data(seg))
691+
pub fn get_path_data(&self, id: NodeId, path: &ast::Path) -> Option<Ref> {
692+
path.segments
693+
.last()
694+
.and_then(|seg| {
695+
self.get_path_segment_data(seg)
696+
.or_else(|| self.get_path_segment_data_with_id(seg, id))
697+
})
693698
}
694699

695700
pub fn get_path_segment_data(&self, path_seg: &ast::PathSegment) -> Option<Ref> {
701+
self.get_path_segment_data_with_id(path_seg, path_seg.id)
702+
}
703+
704+
fn get_path_segment_data_with_id(
705+
&self,
706+
path_seg: &ast::PathSegment,
707+
id: NodeId,
708+
) -> Option<Ref> {
696709
// Returns true if the path is function type sugar, e.g., `Fn(A) -> B`.
697710
fn fn_type(seg: &ast::PathSegment) -> bool {
698711
if let Some(ref generic_args) = seg.args {
@@ -703,11 +716,11 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
703716
false
704717
}
705718

706-
if path_seg.id == DUMMY_NODE_ID {
719+
if id == DUMMY_NODE_ID {
707720
return None;
708721
}
709722

710-
let def = self.get_path_def(path_seg.id);
723+
let def = self.get_path_def(id);
711724
let span = path_seg.ident.span;
712725
filter!(self.span_utils, span);
713726
let span = self.span_from_span(span);

0 commit comments

Comments
 (0)
Please sign in to comment.