save-analysis: document `process_use_tree`
This commit is contained in:
parent
59fafc8889
commit
b3c39560a4
|
@ -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,
|
fn process_use_tree(&mut self,
|
||||||
use_tree: &'l ast::UseTree,
|
use_tree: &'l ast::UseTree,
|
||||||
id: NodeId,
|
id: NodeId,
|
||||||
|
@ -1238,6 +1246,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
||||||
prefix: &ast::Path) {
|
prefix: &ast::Path) {
|
||||||
let path = &use_tree.prefix;
|
let path = &use_tree.prefix;
|
||||||
let access = access_from!(self.save_ctxt, root_item);
|
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)
|
let parent = self.save_ctxt.tcx.hir.opt_local_def_id(id)
|
||||||
.and_then(|id| self.save_ctxt.tcx.parent_def_id(id))
|
.and_then(|id| self.save_ctxt.tcx.parent_def_id(id))
|
||||||
.map(::id_from_def_id);
|
.map(::id_from_def_id);
|
||||||
|
|
Loading…
Reference in New Issue