From b3c39560a43c72fa792241297467e43cf5d1c789 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Thu, 14 Dec 2017 21:19:17 -0500 Subject: [PATCH] save-analysis: document `process_use_tree` --- src/librustc_save_analysis/dump_visitor.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 0da535a922d..08ad96c6fe8 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -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);