Skip to content

Commit 59fafc8

Browse files
committed
save-analysis: add parents to imports
1 parent 77efd68 commit 59fafc8

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

src/Cargo.lock

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/librustc_save_analysis/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ rustc_data_structures = { path = "../librustc_data_structures" }
1515
rustc_typeck = { path = "../librustc_typeck" }
1616
syntax = { path = "../libsyntax" }
1717
syntax_pos = { path = "../libsyntax_pos" }
18-
rls-data = "0.13"
18+
rls-data = "0.14"
1919
rls-span = "0.4"
2020
# FIXME(#40527) should move rustc serialize out of tree
2121
rustc-serialize = "0.3"

src/librustc_save_analysis/dump_visitor.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,10 +1234,13 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
12341234
fn process_use_tree(&mut self,
12351235
use_tree: &'l ast::UseTree,
12361236
id: NodeId,
1237-
parent_item: &'l ast::Item,
1237+
root_item: &'l ast::Item,
12381238
prefix: &ast::Path) {
12391239
let path = &use_tree.prefix;
1240-
let access = access_from!(self.save_ctxt, parent_item);
1240+
let access = access_from!(self.save_ctxt, root_item);
1241+
let parent = self.save_ctxt.tcx.hir.opt_local_def_id(id)
1242+
.and_then(|id| self.save_ctxt.tcx.parent_def_id(id))
1243+
.map(::id_from_def_id);
12411244

12421245
match use_tree.kind {
12431246
ast::UseTreeKind::Simple(ident) => {
@@ -1276,6 +1279,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
12761279
span,
12771280
name: ident.to_string(),
12781281
value: String::new(),
1282+
parent,
12791283
});
12801284
}
12811285
self.write_sub_paths_truncated(&path);
@@ -1311,6 +1315,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
13111315
span,
13121316
name: "*".to_owned(),
13131317
value: names.join(", "),
1318+
parent,
13141319
});
13151320
}
13161321
self.write_sub_paths(&path);
@@ -1325,7 +1330,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
13251330
span: path.span,
13261331
};
13271332
for &(ref tree, id) in nested_items {
1328-
self.process_use_tree(tree, id, parent_item, &prefix);
1333+
self.process_use_tree(tree, id, root_item, &prefix);
13291334
}
13301335
}
13311336
}
@@ -1400,6 +1405,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
14001405
span,
14011406
name: item.ident.to_string(),
14021407
value: String::new(),
1408+
parent: None,
14031409
},
14041410
);
14051411
}

0 commit comments

Comments
 (0)