Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save-analysis: fallback to using path id #56060

Merged
merged 1 commit into from
Nov 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/librustc_save_analysis/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
Expand Down