]>
git.proxmox.com Git - rustc.git/blob - src/librustdoc/doctree.rs
1 // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! This module is used to store stuff from Rust's AST in a more convenient
12 //! manner (and with prettier names) before cleaning.
13 pub use self::StructType
::*;
14 pub use self::TypeBound
::*;
17 use syntax
::codemap
::Span
;
20 use syntax
::ast
::{Name, NodeId}
;
26 pub name
: Option
<Name
>,
27 pub attrs
: hir
::HirVec
<ast
::Attribute
>,
28 pub where_outer
: Span
,
29 pub where_inner
: Span
,
30 pub extern_crates
: Vec
<ExternCrate
>,
31 pub imports
: Vec
<Import
>,
32 pub structs
: Vec
<Struct
>,
34 pub fns
: Vec
<Function
>,
35 pub mods
: Vec
<Module
>,
37 pub typedefs
: Vec
<Typedef
>,
38 pub statics
: Vec
<Static
>,
39 pub constants
: Vec
<Constant
>,
40 pub traits
: Vec
<Trait
>,
41 pub vis
: hir
::Visibility
,
42 pub stab
: Option
<attr
::Stability
>,
43 pub depr
: Option
<attr
::Deprecation
>,
45 pub def_traits
: Vec
<DefaultImpl
>,
46 pub foreigns
: Vec
<hir
::ForeignMod
>,
47 pub macros
: Vec
<Macro
>,
52 pub fn new(name
: Option
<Name
>) -> Module
{
59 where_outer
: syntax
::codemap
::DUMMY_SP
,
60 where_inner
: syntax
::codemap
::DUMMY_SP
,
61 attrs
: hir
::HirVec
::new(),
62 extern_crates
: Vec
::new(),
68 typedefs
: Vec
::new(),
70 constants
: Vec
::new(),
73 def_traits
: Vec
::new(),
74 foreigns
: Vec
::new(),
81 #[derive(Debug, Clone, RustcEncodable, RustcDecodable, Copy)]
87 /// A newtype struct (tuple struct with one element)
95 TraitBound(hir
::TraitRef
)
99 pub vis
: hir
::Visibility
,
100 pub stab
: Option
<attr
::Stability
>,
101 pub depr
: Option
<attr
::Deprecation
>,
103 pub struct_type
: StructType
,
105 pub generics
: hir
::Generics
,
106 pub attrs
: hir
::HirVec
<ast
::Attribute
>,
107 pub fields
: hir
::HirVec
<hir
::StructField
>,
112 pub vis
: hir
::Visibility
,
113 pub stab
: Option
<attr
::Stability
>,
114 pub depr
: Option
<attr
::Deprecation
>,
115 pub variants
: hir
::HirVec
<Variant
>,
116 pub generics
: hir
::Generics
,
117 pub attrs
: hir
::HirVec
<ast
::Attribute
>,
125 pub attrs
: hir
::HirVec
<ast
::Attribute
>,
126 pub def
: hir
::VariantData
,
127 pub stab
: Option
<attr
::Stability
>,
128 pub depr
: Option
<attr
::Deprecation
>,
132 pub struct Function
{
133 pub decl
: hir
::FnDecl
,
134 pub attrs
: hir
::HirVec
<ast
::Attribute
>,
137 pub vis
: hir
::Visibility
,
138 pub stab
: Option
<attr
::Stability
>,
139 pub depr
: Option
<attr
::Deprecation
>,
140 pub unsafety
: hir
::Unsafety
,
141 pub constness
: hir
::Constness
,
143 pub generics
: hir
::Generics
,
149 pub gen
: hir
::Generics
,
152 pub attrs
: hir
::HirVec
<ast
::Attribute
>,
154 pub vis
: hir
::Visibility
,
155 pub stab
: Option
<attr
::Stability
>,
156 pub depr
: Option
<attr
::Deprecation
>,
161 pub type_
: P
<hir
::Ty
>,
162 pub mutability
: hir
::Mutability
,
163 pub expr
: P
<hir
::Expr
>,
165 pub attrs
: hir
::HirVec
<ast
::Attribute
>,
166 pub vis
: hir
::Visibility
,
167 pub stab
: Option
<attr
::Stability
>,
168 pub depr
: Option
<attr
::Deprecation
>,
173 pub struct Constant
{
174 pub type_
: P
<hir
::Ty
>,
175 pub expr
: P
<hir
::Expr
>,
177 pub attrs
: hir
::HirVec
<ast
::Attribute
>,
178 pub vis
: hir
::Visibility
,
179 pub stab
: Option
<attr
::Stability
>,
180 pub depr
: Option
<attr
::Deprecation
>,
186 pub unsafety
: hir
::Unsafety
,
188 pub items
: hir
::HirVec
<hir
::TraitItem
>,
189 pub generics
: hir
::Generics
,
190 pub bounds
: hir
::HirVec
<hir
::TyParamBound
>,
191 pub attrs
: hir
::HirVec
<ast
::Attribute
>,
194 pub vis
: hir
::Visibility
,
195 pub stab
: Option
<attr
::Stability
>,
196 pub depr
: Option
<attr
::Deprecation
>,
200 pub unsafety
: hir
::Unsafety
,
201 pub polarity
: hir
::ImplPolarity
,
202 pub generics
: hir
::Generics
,
203 pub trait_
: Option
<hir
::TraitRef
>,
204 pub for_
: P
<hir
::Ty
>,
205 pub items
: hir
::HirVec
<hir
::ImplItem
>,
206 pub attrs
: hir
::HirVec
<ast
::Attribute
>,
208 pub vis
: hir
::Visibility
,
209 pub stab
: Option
<attr
::Stability
>,
210 pub depr
: Option
<attr
::Deprecation
>,
214 pub struct DefaultImpl
{
215 pub unsafety
: hir
::Unsafety
,
216 pub trait_
: hir
::TraitRef
,
218 pub attrs
: hir
::HirVec
<ast
::Attribute
>,
225 pub attrs
: hir
::HirVec
<ast
::Attribute
>,
227 pub matchers
: hir
::HirVec
<Span
>,
228 pub stab
: Option
<attr
::Stability
>,
229 pub depr
: Option
<attr
::Deprecation
>,
230 pub imported_from
: Option
<Name
>,
233 pub struct ExternCrate
{
235 pub path
: Option
<String
>,
236 pub vis
: hir
::Visibility
,
237 pub attrs
: hir
::HirVec
<ast
::Attribute
>,
243 pub vis
: hir
::Visibility
,
244 pub attrs
: hir
::HirVec
<ast
::Attribute
>,
245 pub node
: hir
::ViewPath_
,
249 pub fn struct_type_from_def(sd
: &hir
::VariantData
) -> StructType
{
251 // We are in a tuple-struct
252 match sd
.fields().len() {