Skip to content

Commit b3c3956

Browse files
committed
save-analysis: document process_use_tree
1 parent 59fafc8 commit b3c3956

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/librustc_save_analysis/dump_visitor.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,13 +1231,23 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
12311231
}
12321232
}
12331233

1234+
/// Dumps imports in a use tree recursively.
1235+
///
1236+
/// A use tree is an import that may contain nested braces (RFC 2128). The `use_tree` parameter
1237+
/// is the current use tree under scrutiny, while `id` and `prefix` are its corresponding node
1238+
/// id and path. `root_item` is the topmost use tree in the hierarchy.
1239+
///
1240+
/// If `use_tree` is a simple or glob import, it is dumped into the analysis data. Otherwise,
1241+
/// each child use tree is dumped recursively.
12341242
fn process_use_tree(&mut self,
12351243
use_tree: &'l ast::UseTree,
12361244
id: NodeId,
12371245
root_item: &'l ast::Item,
12381246
prefix: &ast::Path) {
12391247
let path = &use_tree.prefix;
12401248
let access = access_from!(self.save_ctxt, root_item);
1249+
1250+
// The parent def id of a given use tree is always the enclosing item.
12411251
let parent = self.save_ctxt.tcx.hir.opt_local_def_id(id)
12421252
.and_then(|id| self.save_ctxt.tcx.parent_def_id(id))
12431253
.map(::id_from_def_id);

0 commit comments

Comments
 (0)