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 crate use self::StructType::*;
6 use rustc_span::{self, Span, Symbol};
10 crate struct Module<'hir> {
11 crate name: Option<Symbol>,
12 crate attrs: &'hir [ast::Attribute],
13 crate where_outer: Span,
14 crate where_inner: Span,
15 crate imports: Vec<Import<'hir>>,
16 crate mods: Vec<Module<'hir>>,
19 crate items: Vec<(&'hir hir::Item<'hir>, Option<Symbol>)>,
20 crate foreigns: Vec<(&'hir hir::ForeignItem<'hir>, Option<Symbol>)>,
21 crate macros: Vec<(&'hir hir::MacroDef<'hir>, Option<Symbol>)>,
26 crate fn new(name: Option<Symbol>, attrs: &'hir [ast::Attribute]) -> Module<'hir> {
29 id: hir::CRATE_HIR_ID,
30 where_outer: rustc_span::DUMMY_SP,
31 where_inner: rustc_span::DUMMY_SP,
43 #[derive(Debug, Clone, Copy)]
44 crate enum StructType {
53 crate struct Variant<'hir> {
56 crate def: &'hir hir::VariantData<'hir>,
60 crate struct Import<'hir> {
63 crate vis: &'hir hir::Visibility<'hir>,
64 crate attrs: &'hir [ast::Attribute],
65 crate path: &'hir hir::Path<'hir>,
70 crate fn struct_type_from_def(vdata: &hir::VariantData<'_>) -> StructType {
72 hir::VariantData::Struct(..) => Plain,
73 hir::VariantData::Tuple(..) => Tuple,
74 hir::VariantData::Unit(..) => Unit,