save-analysis: document `process_use_tree`

This commit is contained in:
Andy Russell 2017-12-14 21:19:17 -05:00
parent 59fafc8889
commit b3c39560a4
No known key found for this signature in database
GPG Key ID: BE2221033EDBC374
1 changed files with 10 additions and 0 deletions

View File

@ -1231,6 +1231,14 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
}
}
/// Dumps imports in a use tree recursively.
///
/// A use tree is an import that may contain nested braces (RFC 2128). The `use_tree` parameter
/// is the current use tree under scrutiny, while `id` and `prefix` are its corresponding node
/// id and path. `root_item` is the topmost use tree in the hierarchy.
///
/// If `use_tree` is a simple or glob import, it is dumped into the analysis data. Otherwise,
/// each child use tree is dumped recursively.
fn process_use_tree(&mut self,
use_tree: &'l ast::UseTree,
id: NodeId,
@ -1238,6 +1246,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
prefix: &ast::Path) {
let path = &use_tree.prefix;
let access = access_from!(self.save_ctxt, root_item);
// The parent def id of a given use tree is always the enclosing item.
let parent = self.save_ctxt.tcx.hir.opt_local_def_id(id)
.and_then(|id| self.save_ctxt.tcx.parent_def_id(id))
.map(::id_from_def_id);