]> git.proxmox.com Git - rustc.git/blob - src/librustdoc/doctree.rs
New upstream version 1.54.0+dfsg1
[rustc.git] / src / librustdoc / doctree.rs
1 //! This module is used to store stuff from Rust's AST in a more convenient
2 //! manner (and with prettier names) before cleaning.
3 use rustc_middle::ty::TyCtxt;
4 use rustc_span::{self, Span, Symbol};
5
6 use rustc_hir as hir;
7
8 crate struct Module<'hir> {
9 crate name: Symbol,
10 crate where_inner: Span,
11 crate mods: Vec<Module<'hir>>,
12 crate id: hir::HirId,
13 // (item, renamed)
14 crate items: Vec<(&'hir hir::Item<'hir>, Option<Symbol>)>,
15 crate foreigns: Vec<(&'hir hir::ForeignItem<'hir>, Option<Symbol>)>,
16 crate macros: Vec<(&'hir hir::MacroDef<'hir>, Option<Symbol>)>,
17 }
18
19 impl Module<'hir> {
20 crate fn new(name: Symbol, id: hir::HirId, where_inner: Span) -> Module<'hir> {
21 Module {
22 name,
23 id,
24 where_inner,
25 mods: Vec::new(),
26 items: Vec::new(),
27 foreigns: Vec::new(),
28 macros: Vec::new(),
29 }
30 }
31
32 crate fn where_outer(&self, tcx: TyCtxt<'_>) -> Span {
33 tcx.hir().span(self.id)
34 }
35 }