]> git.lizzy.rs Git - rust.git/commitdiff
save-analysis: document `process_use_tree`
authorAndy Russell <arussell123@gmail.com>
Fri, 15 Dec 2017 02:19:17 +0000 (21:19 -0500)
committerAndy Russell <arussell123@gmail.com>
Fri, 15 Dec 2017 21:57:51 +0000 (16:57 -0500)
src/librustc_save_analysis/dump_visitor.rs

index 0da535a922db67a813134e300fdfa8989cead771..08ad96c6fe898b7c0884eb449e1add0178d48d0c 100644 (file)
@@ -1231,6 +1231,14 @@ fn process_impl_item(&mut self, impl_item: &'l ast::ImplItem, impl_id: DefId) {
         }
     }
 
+    /// 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 @@ fn process_use_tree(&mut self,
                          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);