diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2018-11-19 16:28:57 +1300 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2018-11-19 17:18:36 +1300 |
| commit | 99d1513ed336a593f06addaf0c6c2dc22951f5db (patch) | |
| tree | 29850a9d6ee8d02c5bf3966d2a2e413a09b9c1c0 | |
| parent | f37247f885026d29bf26fd4aed6e9135e4f32ebf (diff) | |
| download | rust-99d1513ed336a593f06addaf0c6c2dc22951f5db.tar.gz rust-99d1513ed336a593f06addaf0c6c2dc22951f5db.zip | |
save-analysis: fallback to using path id
| -rw-r--r-- | src/librustc_save_analysis/lib.rs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 7689406b59a..82c4795a29d 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -688,11 +688,24 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } } - pub fn get_path_data(&self, _id: NodeId, path: &ast::Path) -> Option<Ref> { - path.segments.last().and_then(|seg| self.get_path_segment_data(seg)) + pub fn get_path_data(&self, id: NodeId, path: &ast::Path) -> Option<Ref> { + path.segments + .last() + .and_then(|seg| { + self.get_path_segment_data(seg) + .or_else(|| self.get_path_segment_data_with_id(seg, id)) + }) } pub fn get_path_segment_data(&self, path_seg: &ast::PathSegment) -> Option<Ref> { + self.get_path_segment_data_with_id(path_seg, path_seg.id) + } + + fn get_path_segment_data_with_id( + &self, + path_seg: &ast::PathSegment, + id: NodeId, + ) -> Option<Ref> { // Returns true if the path is function type sugar, e.g., `Fn(A) -> B`. fn fn_type(seg: &ast::PathSegment) -> bool { if let Some(ref generic_args) = seg.args { @@ -703,11 +716,11 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { false } - if path_seg.id == DUMMY_NODE_ID { + if id == DUMMY_NODE_ID { return None; } - let def = self.get_path_def(path_seg.id); + let def = self.get_path_def(id); let span = path_seg.ident.span; filter!(self.span_utils, span); let span = self.span_from_span(span); |
