X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustdoc%2Fvisit_ast.rs;h=379de080ffd4d8833fe14b80a3857d3d35a7bda6;hb=1e55c31cbbc43a21c93ed5652dc39c267e6557af;hp=1191a94a7039bee6bf544d7d182dc31e706867c9;hpb=160602b48526b857ff838708eece72c9db55c95c;p=rust.git diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 1191a94a703..379de080ffd 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -11,12 +11,35 @@ use rustc_middle::ty::TyCtxt; use rustc_span::def_id::{CRATE_DEF_ID, LOCAL_CRATE}; use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::Span; use std::mem; use crate::clean::{self, cfg::Cfg, AttributesExt, NestedAttributesExt}; use crate::core; -use crate::doctree::*; + +/// This module is used to store stuff from Rust's AST in a more convenient +/// manner (and with prettier names) before cleaning. +#[derive(Debug)] +crate struct Module<'hir> { + crate name: Symbol, + crate where_inner: Span, + crate mods: Vec>, + crate id: hir::HirId, + // (item, renamed) + crate items: Vec<(&'hir hir::Item<'hir>, Option)>, + crate foreigns: Vec<(&'hir hir::ForeignItem<'hir>, Option)>, +} + +impl Module<'hir> { + crate fn new(name: Symbol, id: hir::HirId, where_inner: Span) -> Module<'hir> { + Module { name, id, where_inner, mods: Vec::new(), items: Vec::new(), foreigns: Vec::new() } + } + + crate fn where_outer(&self, tcx: TyCtxt<'_>) -> Span { + tcx.hir().span(self.id) + } +} // FIXME: Should this be replaced with tcx.def_path_str? fn def_id_to_path(tcx: TyCtxt<'_>, did: DefId) -> Vec {