]>
git.proxmox.com Git - rustc.git/blob - src/librustdoc/doctree.rs
8fa92304d249cb9d3adcfdba00d3b77e6250992c
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
;
21 use syntax
::ast
::{Ident, NodeId}
;
25 pub name
: Option
<Ident
>,
26 pub attrs
: Vec
<ast
::Attribute
>,
27 pub where_outer
: Span
,
28 pub where_inner
: Span
,
29 pub extern_crates
: Vec
<ExternCrate
>,
30 pub imports
: Vec
<Import
>,
31 pub structs
: Vec
<Struct
>,
33 pub fns
: Vec
<Function
>,
34 pub mods
: Vec
<Module
>,
36 pub typedefs
: Vec
<Typedef
>,
37 pub statics
: Vec
<Static
>,
38 pub constants
: Vec
<Constant
>,
39 pub traits
: Vec
<Trait
>,
40 pub vis
: ast
::Visibility
,
41 pub stab
: Option
<attr
::Stability
>,
43 pub def_traits
: Vec
<DefaultImpl
>,
44 pub foreigns
: Vec
<ast
::ForeignMod
>,
45 pub macros
: Vec
<Macro
>,
50 pub fn new(name
: Option
<Ident
>) -> Module
{
56 where_outer
: syntax
::codemap
::DUMMY_SP
,
57 where_inner
: syntax
::codemap
::DUMMY_SP
,
59 extern_crates
: Vec
::new(),
65 typedefs
: Vec
::new(),
67 constants
: Vec
::new(),
70 def_traits
: Vec
::new(),
71 foreigns
: Vec
::new(),
78 #[derive(Debug, Clone, RustcEncodable, RustcDecodable, Copy)]
84 /// A newtype struct (tuple struct with one element)
92 TraitBound(ast
::TraitRef
)
96 pub vis
: ast
::Visibility
,
97 pub stab
: Option
<attr
::Stability
>,
99 pub struct_type
: StructType
,
101 pub generics
: ast
::Generics
,
102 pub attrs
: Vec
<ast
::Attribute
>,
103 pub fields
: Vec
<ast
::StructField
>,
108 pub vis
: ast
::Visibility
,
109 pub stab
: Option
<attr
::Stability
>,
110 pub variants
: Vec
<Variant
>,
111 pub generics
: ast
::Generics
,
112 pub attrs
: Vec
<ast
::Attribute
>,
120 pub attrs
: Vec
<ast
::Attribute
>,
121 pub kind
: ast
::VariantKind
,
123 pub vis
: ast
::Visibility
,
124 pub stab
: Option
<attr
::Stability
>,
128 pub struct Function
{
129 pub decl
: ast
::FnDecl
,
130 pub attrs
: Vec
<ast
::Attribute
>,
133 pub vis
: ast
::Visibility
,
134 pub stab
: Option
<attr
::Stability
>,
135 pub unsafety
: ast
::Unsafety
,
137 pub generics
: ast
::Generics
,
143 pub gen
: ast
::Generics
,
146 pub attrs
: Vec
<ast
::Attribute
>,
148 pub vis
: ast
::Visibility
,
149 pub stab
: Option
<attr
::Stability
>,
154 pub type_
: P
<ast
::Ty
>,
155 pub mutability
: ast
::Mutability
,
156 pub expr
: P
<ast
::Expr
>,
158 pub attrs
: Vec
<ast
::Attribute
>,
159 pub vis
: ast
::Visibility
,
160 pub stab
: Option
<attr
::Stability
>,
165 pub struct Constant
{
166 pub type_
: P
<ast
::Ty
>,
167 pub expr
: P
<ast
::Expr
>,
169 pub attrs
: Vec
<ast
::Attribute
>,
170 pub vis
: ast
::Visibility
,
171 pub stab
: Option
<attr
::Stability
>,
177 pub unsafety
: ast
::Unsafety
,
179 pub items
: Vec
<P
<ast
::TraitItem
>>, //should be TraitItem
180 pub generics
: ast
::Generics
,
181 pub bounds
: Vec
<ast
::TyParamBound
>,
182 pub attrs
: Vec
<ast
::Attribute
>,
185 pub vis
: ast
::Visibility
,
186 pub stab
: Option
<attr
::Stability
>,
190 pub unsafety
: ast
::Unsafety
,
191 pub polarity
: ast
::ImplPolarity
,
192 pub generics
: ast
::Generics
,
193 pub trait_
: Option
<ast
::TraitRef
>,
194 pub for_
: P
<ast
::Ty
>,
195 pub items
: Vec
<P
<ast
::ImplItem
>>,
196 pub attrs
: Vec
<ast
::Attribute
>,
198 pub vis
: ast
::Visibility
,
199 pub stab
: Option
<attr
::Stability
>,
203 pub struct DefaultImpl
{
204 pub unsafety
: ast
::Unsafety
,
205 pub trait_
: ast
::TraitRef
,
207 pub attrs
: Vec
<ast
::Attribute
>,
214 pub attrs
: Vec
<ast
::Attribute
>,
216 pub stab
: Option
<attr
::Stability
>,
217 pub imported_from
: Option
<Ident
>,
220 pub struct ExternCrate
{
222 pub path
: Option
<String
>,
223 pub vis
: ast
::Visibility
,
224 pub attrs
: Vec
<ast
::Attribute
>,
230 pub vis
: ast
::Visibility
,
231 pub attrs
: Vec
<ast
::Attribute
>,
232 pub node
: ast
::ViewPath_
,
236 pub fn struct_type_from_def(sd
: &ast
::StructDef
) -> StructType
{
237 if sd
.ctor_id
.is_some() {
238 // We are in a tuple-struct
239 match sd
.fields
.len() {