(index<- ) ./librustdoc/clean.rs
git branch: * master 5200215 auto merge of #14035 : alexcrichton/rust/experimental, r=huonw
modified: Fri May 9 13:02:28 2014
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.
4 //
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.
10
11 //! This module contains the "cleaned" pieces of the AST, and the functions
12 //! that clean them.
13
14 use syntax;
15 use syntax::ast;
16 use syntax::ast_util;
17 use syntax::attr;
18 use syntax::attr::AttributeMethods;
19 use syntax::codemap::Pos;
20 use syntax::parse::token::InternedString;
21 use syntax::parse::token;
22
23 use rustc::back::link;
24 use rustc::driver::driver;
25 use rustc::metadata::cstore;
26 use rustc::metadata::csearch;
27 use rustc::metadata::decoder;
28
29 use std::strbuf::StrBuf;
30
31 use core;
32 use doctree;
33 use visit_ast;
34
35 /// A stable identifier to the particular version of JSON output.
36 /// Increment this when the `Crate` and related structures change.
37 pub static SCHEMA_VERSION: &'static str = "0.8.2";
38
39 pub trait Clean<T> {
40 fn clean(&self) -> T;
41 }
42
43 impl<T: Clean<U>, U> Clean<Vec<U>> for Vec<T> {
44 fn clean(&self) -> Vec<U> {
45 self.iter().map(|x| x.clean()).collect()
46 }
47 }
48
49 impl<T: Clean<U>, U> Clean<U> for @T {
50 fn clean(&self) -> U {
51 (**self).clean()
52 }
53 }
54
55 impl<T: Clean<U>, U> Clean<Option<U>> for Option<T> {
56 fn clean(&self) -> Option<U> {
57 match self {
58 &None => None,
59 &Some(ref v) => Some(v.clean())
60 }
61 }
62 }
63
64 impl<T: Clean<U>, U> Clean<Vec<U>> for syntax::owned_slice::OwnedSlice<T> {
65 fn clean(&self) -> Vec<U> {
66 self.iter().map(|x| x.clean()).collect()
67 }
68 }
69
70 #[deriving(Clone, Encodable, Decodable)]
71 pub struct Crate {
72 pub name: ~str,
73 pub module: Option<Item>,
74 pub externs: Vec<(ast::CrateNum, ExternalCrate)>,
75 }
76
77 impl<'a> Clean<Crate> for visit_ast::RustdocVisitor<'a> {
78 fn clean(&self) -> Crate {
79 let cx = super::ctxtkey.get().unwrap();
80
81 let mut externs = Vec::new();
82 cx.sess().cstore.iter_crate_data(|n, meta| {
83 externs.push((n, meta.clean()));
84 });
85
86 let input = driver::FileInput(cx.src.clone());
87 let t_outputs = driver::build_output_filenames(&input,
88 &None,
89 &None,
90 self.attrs.as_slice(),
91 cx.sess());
92 let id = link::find_crate_id(self.attrs.as_slice(),
93 t_outputs.out_filestem);
94 Crate {
95 name: id.name.to_owned(),
96 module: Some(self.module.clean()),
97 externs: externs,
98 }
99 }
100 }
101
102 #[deriving(Clone, Encodable, Decodable)]
103 pub struct ExternalCrate {
104 pub name: ~str,
105 pub attrs: Vec<Attribute>,
106 }
107
108 impl Clean<ExternalCrate> for cstore::crate_metadata {
109 fn clean(&self) -> ExternalCrate {
110 ExternalCrate {
111 name: self.name.to_owned(),
112 attrs: decoder::get_crate_attributes(self.data()).clean()
113 .move_iter()
114 .collect(),
115 }
116 }
117 }
118
119 /// Anything with a source location and set of attributes and, optionally, a
120 /// name. That is, anything that can be documented. This doesn't correspond
121 /// directly to the AST's concept of an item; it's a strict superset.
122 #[deriving(Clone, Encodable, Decodable)]
123 pub struct Item {
124 /// Stringified span
125 pub source: Span,
126 /// Not everything has a name. E.g., impls
127 pub name: Option<~str>,
128 pub attrs: Vec<Attribute> ,
129 pub inner: ItemEnum,
130 pub visibility: Option<Visibility>,
131 pub id: ast::NodeId,
132 }
133
134 impl Item {
135 /// Finds the `doc` attribute as a List and returns the list of attributes
136 /// nested inside.
137 pub fn doc_list<'a>(&'a self) -> Option<&'a [Attribute]> {
138 for attr in self.attrs.iter() {
139 match *attr {
140 List(ref x, ref list) if "doc" == *x => { return Some(list.as_slice()); }
141 _ => {}
142 }
143 }
144 return None;
145 }
146
147 /// Finds the `doc` attribute as a NameValue and returns the corresponding
148 /// value found.
149 pub fn doc_value<'a>(&'a self) -> Option<&'a str> {
150 for attr in self.attrs.iter() {
151 match *attr {
152 NameValue(ref x, ref v) if "doc" == *x => { return Some(v.as_slice()); }
153 _ => {}
154 }
155 }
156 return None;
157 }
158
159 pub fn is_hidden_from_doc(&self) -> bool {
160 match self.doc_list() {
161 Some(ref l) => {
162 for innerattr in l.iter() {
163 match *innerattr {
164 Word(ref s) if "hidden" == *s => return true,
165 _ => (),
166 }
167 }
168 },
169 None => ()
170 }
171 return false;
172 }
173
174 pub fn is_mod(&self) -> bool {
175 match self.inner { ModuleItem(..) => true, _ => false }
176 }
177 pub fn is_trait(&self) -> bool {
178 match self.inner { TraitItem(..) => true, _ => false }
179 }
180 pub fn is_struct(&self) -> bool {
181 match self.inner { StructItem(..) => true, _ => false }
182 }
183 pub fn is_enum(&self) -> bool {
184 match self.inner { EnumItem(..) => true, _ => false }
185 }
186 pub fn is_fn(&self) -> bool {
187 match self.inner { FunctionItem(..) => true, _ => false }
188 }
189 }
190
191 #[deriving(Clone, Encodable, Decodable)]
192 pub enum ItemEnum {
193 StructItem(Struct),
194 EnumItem(Enum),
195 FunctionItem(Function),
196 ModuleItem(Module),
197 TypedefItem(Typedef),
198 StaticItem(Static),
199 TraitItem(Trait),
200 ImplItem(Impl),
201 /// `use` and `extern crate`
202 ViewItemItem(ViewItem),
203 /// A method signature only. Used for required methods in traits (ie,
204 /// non-default-methods).
205 TyMethodItem(TyMethod),
206 /// A method with a body.
207 MethodItem(Method),
208 StructFieldItem(StructField),
209 VariantItem(Variant),
210 /// `fn`s from an extern block
211 ForeignFunctionItem(Function),
212 /// `static`s from an extern block
213 ForeignStaticItem(Static),
214 MacroItem(Macro),
215 }
216
217 #[deriving(Clone, Encodable, Decodable)]
218 pub struct Module {
219 pub items: Vec<Item>,
220 pub is_crate: bool,
221 }
222
223 impl Clean<Item> for doctree::Module {
224 fn clean(&self) -> Item {
225 let name = if self.name.is_some() {
226 self.name.unwrap().clean()
227 } else {
228 "".to_owned()
229 };
230 let mut foreigns = Vec::new();
231 for subforeigns in self.foreigns.clean().move_iter() {
232 for foreign in subforeigns.move_iter() {
233 foreigns.push(foreign)
234 }
235 }
236 let items: Vec<Vec<Item> > = vec!(
237 self.structs.clean().move_iter().collect(),
238 self.enums.clean().move_iter().collect(),
239 self.fns.clean().move_iter().collect(),
240 foreigns,
241 self.mods.clean().move_iter().collect(),
242 self.typedefs.clean().move_iter().collect(),
243 self.statics.clean().move_iter().collect(),
244 self.traits.clean().move_iter().collect(),
245 self.impls.clean().move_iter().collect(),
246 self.view_items.clean().move_iter().collect(),
247 self.macros.clean().move_iter().collect()
248 );
249
250 // determine if we should display the inner contents or
251 // the outer `mod` item for the source code.
252 let where = {
253 let ctxt = super::ctxtkey.get().unwrap();
254 let cm = ctxt.sess().codemap();
255 let outer = cm.lookup_char_pos(self.where_outer.lo);
256 let inner = cm.lookup_char_pos(self.where_inner.lo);
257 if outer.file.start_pos == inner.file.start_pos {
258 // mod foo { ... }
259 self.where_outer
260 } else {
261 // mod foo; (and a separate FileMap for the contents)
262 self.where_inner
263 }
264 };
265
266 Item {
267 name: Some(name),
268 attrs: self.attrs.clean(),
269 source: where.clean(),
270 visibility: self.vis.clean(),
271 id: self.id,
272 inner: ModuleItem(Module {
273 is_crate: self.is_crate,
274 items: items.iter()
275 .flat_map(|x| x.iter().map(|x| (*x).clone()))
276 .collect(),
277 })
278 }
279 }
280 }
281
282 #[deriving(Clone, Encodable, Decodable)]
283 pub enum Attribute {
284 Word(~str),
285 List(~str, Vec<Attribute> ),
286 NameValue(~str, ~str)
287 }
288
289 impl Clean<Attribute> for ast::MetaItem {
290 fn clean(&self) -> Attribute {
291 match self.node {
292 ast::MetaWord(ref s) => Word(s.get().to_owned()),
293 ast::MetaList(ref s, ref l) => {
294 List(s.get().to_owned(), l.clean().move_iter().collect())
295 }
296 ast::MetaNameValue(ref s, ref v) => {
297 NameValue(s.get().to_owned(), lit_to_str(v))
298 }
299 }
300 }
301 }
302
303 impl Clean<Attribute> for ast::Attribute {
304 fn clean(&self) -> Attribute {
305 self.desugar_doc().node.value.clean()
306 }
307 }
308
309 // This is a rough approximation that gets us what we want.
310 impl<'a> attr::AttrMetaMethods for &'a Attribute {
311 fn name(&self) -> InternedString {
312 match **self {
313 Word(ref n) | List(ref n, _) | NameValue(ref n, _) => {
314 token::intern_and_get_ident(*n)
315 }
316 }
317 }
318
319 fn value_str(&self) -> Option<InternedString> {
320 match **self {
321 NameValue(_, ref v) => Some(token::intern_and_get_ident(*v)),
322 _ => None,
323 }
324 }
325 fn meta_item_list<'a>(&'a self) -> Option<&'a [@ast::MetaItem]> { None }
326 fn name_str_pair(&self) -> Option<(InternedString, InternedString)> {
327 None
328 }
329 }
330
331 #[deriving(Clone, Encodable, Decodable)]
332 pub struct TyParam {
333 pub name: ~str,
334 pub id: ast::NodeId,
335 pub bounds: Vec<TyParamBound>,
336 }
337
338 impl Clean<TyParam> for ast::TyParam {
339 fn clean(&self) -> TyParam {
340 TyParam {
341 name: self.ident.clean(),
342 id: self.id,
343 bounds: self.bounds.clean().move_iter().collect(),
344 }
345 }
346 }
347
348 #[deriving(Clone, Encodable, Decodable)]
349 pub enum TyParamBound {
350 RegionBound,
351 TraitBound(Type)
352 }
353
354 impl Clean<TyParamBound> for ast::TyParamBound {
355 fn clean(&self) -> TyParamBound {
356 match *self {
357 ast::StaticRegionTyParamBound => RegionBound,
358 ast::OtherRegionTyParamBound(_) => RegionBound,
359 ast::TraitTyParamBound(ref t) => TraitBound(t.clean()),
360 }
361 }
362 }
363
364 #[deriving(Clone, Encodable, Decodable)]
365 pub struct Lifetime(~str);
366
367 impl Lifetime {
368 pub fn get_ref<'a>(&'a self) -> &'a str {
369 let Lifetime(ref s) = *self;
370 let s: &'a str = *s;
371 return s;
372 }
373 }
374
375 impl Clean<Lifetime> for ast::Lifetime {
376 fn clean(&self) -> Lifetime {
377 Lifetime(token::get_name(self.name).get().to_owned())
378 }
379 }
380
381 // maybe use a Generic enum and use ~[Generic]?
382 #[deriving(Clone, Encodable, Decodable)]
383 pub struct Generics {
384 pub lifetimes: Vec<Lifetime>,
385 pub type_params: Vec<TyParam>,
386 }
387
388 impl Clean<Generics> for ast::Generics {
389 fn clean(&self) -> Generics {
390 Generics {
391 lifetimes: self.lifetimes.clean().move_iter().collect(),
392 type_params: self.ty_params.clean().move_iter().collect(),
393 }
394 }
395 }
396
397 #[deriving(Clone, Encodable, Decodable)]
398 pub struct Method {
399 pub generics: Generics,
400 pub self_: SelfTy,
401 pub fn_style: ast::FnStyle,
402 pub decl: FnDecl,
403 }
404
405 impl Clean<Item> for ast::Method {
406 fn clean(&self) -> Item {
407 let inputs = match self.explicit_self.node {
408 ast::SelfStatic => self.decl.inputs.as_slice(),
409 _ => self.decl.inputs.slice_from(1)
410 };
411 let decl = FnDecl {
412 inputs: Arguments {
413 values: inputs.iter().map(|x| x.clean()).collect(),
414 },
415 output: (self.decl.output.clean()),
416 cf: self.decl.cf.clean(),
417 attrs: Vec::new()
418 };
419 Item {
420 name: Some(self.ident.clean()),
421 attrs: self.attrs.clean().move_iter().collect(),
422 source: self.span.clean(),
423 id: self.id.clone(),
424 visibility: self.vis.clean(),
425 inner: MethodItem(Method {
426 generics: self.generics.clean(),
427 self_: self.explicit_self.clean(),
428 fn_style: self.fn_style.clone(),
429 decl: decl,
430 }),
431 }
432 }
433 }
434
435 #[deriving(Clone, Encodable, Decodable)]
436 pub struct TyMethod {
437 pub fn_style: ast::FnStyle,
438 pub decl: FnDecl,
439 pub generics: Generics,
440 pub self_: SelfTy,
441 }
442
443 impl Clean<Item> for ast::TypeMethod {
444 fn clean(&self) -> Item {
445 let inputs = match self.explicit_self.node {
446 ast::SelfStatic => self.decl.inputs.as_slice(),
447 _ => self.decl.inputs.slice_from(1)
448 };
449 let decl = FnDecl {
450 inputs: Arguments {
451 values: inputs.iter().map(|x| x.clean()).collect(),
452 },
453 output: (self.decl.output.clean()),
454 cf: self.decl.cf.clean(),
455 attrs: Vec::new()
456 };
457 Item {
458 name: Some(self.ident.clean()),
459 attrs: self.attrs.clean().move_iter().collect(),
460 source: self.span.clean(),
461 id: self.id,
462 visibility: None,
463 inner: TyMethodItem(TyMethod {
464 fn_style: self.fn_style.clone(),
465 decl: decl,
466 self_: self.explicit_self.clean(),
467 generics: self.generics.clean(),
468 }),
469 }
470 }
471 }
472
473 #[deriving(Clone, Encodable, Decodable)]
474 pub enum SelfTy {
475 SelfStatic,
476 SelfValue,
477 SelfBorrowed(Option<Lifetime>, Mutability),
478 SelfOwned,
479 }
480
481 impl Clean<SelfTy> for ast::ExplicitSelf {
482 fn clean(&self) -> SelfTy {
483 match self.node {
484 ast::SelfStatic => SelfStatic,
485 ast::SelfValue => SelfValue,
486 ast::SelfUniq => SelfOwned,
487 ast::SelfRegion(lt, mt) => SelfBorrowed(lt.clean(), mt.clean()),
488 }
489 }
490 }
491
492 #[deriving(Clone, Encodable, Decodable)]
493 pub struct Function {
494 pub decl: FnDecl,
495 pub generics: Generics,
496 pub fn_style: ast::FnStyle,
497 }
498
499 impl Clean<Item> for doctree::Function {
500 fn clean(&self) -> Item {
501 Item {
502 name: Some(self.name.clean()),
503 attrs: self.attrs.clean(),
504 source: self.where.clean(),
505 visibility: self.vis.clean(),
506 id: self.id,
507 inner: FunctionItem(Function {
508 decl: self.decl.clean(),
509 generics: self.generics.clean(),
510 fn_style: self.fn_style,
511 }),
512 }
513 }
514 }
515
516 #[deriving(Clone, Encodable, Decodable)]
517 pub struct ClosureDecl {
518 pub lifetimes: Vec<Lifetime>,
519 pub decl: FnDecl,
520 pub onceness: ast::Onceness,
521 pub fn_style: ast::FnStyle,
522 pub bounds: Vec<TyParamBound>,
523 }
524
525 impl Clean<ClosureDecl> for ast::ClosureTy {
526 fn clean(&self) -> ClosureDecl {
527 ClosureDecl {
528 lifetimes: self.lifetimes.clean().move_iter().collect(),
529 decl: self.decl.clean(),
530 onceness: self.onceness,
531 fn_style: self.fn_style,
532 bounds: match self.bounds {
533 Some(ref x) => x.clean().move_iter().collect(),
534 None => Vec::new()
535 },
536 }
537 }
538 }
539
540 #[deriving(Clone, Encodable, Decodable)]
541 pub struct FnDecl {
542 pub inputs: Arguments,
543 pub output: Type,
544 pub cf: RetStyle,
545 pub attrs: Vec<Attribute>,
546 }
547
548 #[deriving(Clone, Encodable, Decodable)]
549 pub struct Arguments {
550 pub values: Vec<Argument>,
551 }
552
553 impl Clean<FnDecl> for ast::FnDecl {
554 fn clean(&self) -> FnDecl {
555 FnDecl {
556 inputs: Arguments {
557 values: self.inputs.iter().map(|x| x.clean()).collect(),
558 },
559 output: (self.output.clean()),
560 cf: self.cf.clean(),
561 attrs: Vec::new()
562 }
563 }
564 }
565
566 #[deriving(Clone, Encodable, Decodable)]
567 pub struct Argument {
568 pub type_: Type,
569 pub name: ~str,
570 pub id: ast::NodeId,
571 }
572
573 impl Clean<Argument> for ast::Arg {
574 fn clean(&self) -> Argument {
575 Argument {
576 name: name_from_pat(self.pat),
577 type_: (self.ty.clean()),
578 id: self.id
579 }
580 }
581 }
582
583 #[deriving(Clone, Encodable, Decodable)]
584 pub enum RetStyle {
585 NoReturn,
586 Return
587 }
588
589 impl Clean<RetStyle> for ast::RetStyle {
590 fn clean(&self) -> RetStyle {
591 match *self {
592 ast::Return => Return,
593 ast::NoReturn => NoReturn
594 }
595 }
596 }
597
598 #[deriving(Clone, Encodable, Decodable)]
599 pub struct Trait {
600 pub methods: Vec<TraitMethod>,
601 pub generics: Generics,
602 pub parents: Vec<Type>,
603 }
604
605 impl Clean<Item> for doctree::Trait {
606 fn clean(&self) -> Item {
607 Item {
608 name: Some(self.name.clean()),
609 attrs: self.attrs.clean(),
610 source: self.where.clean(),
611 id: self.id,
612 visibility: self.vis.clean(),
613 inner: TraitItem(Trait {
614 methods: self.methods.clean(),
615 generics: self.generics.clean(),
616 parents: self.parents.clean(),
617 }),
618 }
619 }
620 }
621
622 impl Clean<Type> for ast::TraitRef {
623 fn clean(&self) -> Type {
624 resolve_type(self.path.clean(), None, self.ref_id)
625 }
626 }
627
628 #[deriving(Clone, Encodable, Decodable)]
629 pub enum TraitMethod {
630 Required(Item),
631 Provided(Item),
632 }
633
634 impl TraitMethod {
635 pub fn is_req(&self) -> bool {
636 match self {
637 &Required(..) => true,
638 _ => false,
639 }
640 }
641 pub fn is_def(&self) -> bool {
642 match self {
643 &Provided(..) => true,
644 _ => false,
645 }
646 }
647 pub fn item<'a>(&'a self) -> &'a Item {
648 match *self {
649 Required(ref item) => item,
650 Provided(ref item) => item,
651 }
652 }
653 }
654
655 impl Clean<TraitMethod> for ast::TraitMethod {
656 fn clean(&self) -> TraitMethod {
657 match self {
658 &ast::Required(ref t) => Required(t.clean()),
659 &ast::Provided(ref t) => Provided(t.clean()),
660 }
661 }
662 }
663
664 /// A representation of a Type suitable for hyperlinking purposes. Ideally one can get the original
665 /// type out of the AST/ty::ctxt given one of these, if more information is needed. Most importantly
666 /// it does not preserve mutability or boxes.
667 #[deriving(Clone, Encodable, Decodable)]
668 pub enum Type {
669 /// structs/enums/traits (anything that'd be an ast::TyPath)
670 ResolvedPath {
671 pub path: Path,
672 pub typarams: Option<Vec<TyParamBound>>,
673 pub id: ast::NodeId,
674 },
675 /// Same as above, but only external variants
676 ExternalPath {
677 pub path: Path,
678 pub typarams: Option<Vec<TyParamBound>>,
679 pub fqn: Vec<~str>,
680 pub kind: TypeKind,
681 pub krate: ast::CrateNum,
682 },
683 // I have no idea how to usefully use this.
684 TyParamBinder(ast::NodeId),
685 /// For parameterized types, so the consumer of the JSON don't go looking
686 /// for types which don't exist anywhere.
687 Generic(ast::NodeId),
688 /// For references to self
689 Self(ast::NodeId),
690 /// Primitives are just the fixed-size numeric types (plus int/uint/float), and char.
691 Primitive(ast::PrimTy),
692 Closure(Box<ClosureDecl>, Option<Lifetime>),
693 Proc(Box<ClosureDecl>),
694 /// extern "ABI" fn
695 BareFunction(Box<BareFunctionDecl>),
696 Tuple(Vec<Type>),
697 Vector(Box<Type>),
698 FixedVector(Box<Type>, ~str),
699 String,
700 Bool,
701 /// aka TyNil
702 Unit,
703 /// aka TyBot
704 Bottom,
705 Unique(Box<Type>),
706 Managed(Box<Type>),
707 RawPointer(Mutability, Box<Type>),
708 BorrowedRef {
709 pub lifetime: Option<Lifetime>,
710 pub mutability: Mutability,
711 pub type_: Box<Type>,
712 },
713 // region, raw, other boxes, mutable
714 }
715
716 #[deriving(Clone, Encodable, Decodable)]
717 pub enum TypeKind {
718 TypeStruct,
719 TypeEnum,
720 TypeTrait,
721 TypeFunction,
722 }
723
724 impl Clean<Type> for ast::Ty {
725 fn clean(&self) -> Type {
726 use syntax::ast::*;
727 debug!("cleaning type `{:?}`", self);
728 let ctxt = super::ctxtkey.get().unwrap();
729 let codemap = ctxt.sess().codemap();
730 debug!("span corresponds to `{}`", codemap.span_to_str(self.span));
731 match self.node {
732 TyNil => Unit,
733 TyPtr(ref m) => RawPointer(m.mutbl.clean(), box m.ty.clean()),
734 TyRptr(ref l, ref m) =>
735 BorrowedRef {lifetime: l.clean(), mutability: m.mutbl.clean(),
736 type_: box m.ty.clean()},
737 TyBox(ty) => Managed(box ty.clean()),
738 TyUniq(ty) => Unique(box ty.clean()),
739 TyVec(ty) => Vector(box ty.clean()),
740 TyFixedLengthVec(ty, ref e) => FixedVector(box ty.clean(),
741 e.span.to_src()),
742 TyTup(ref tys) => Tuple(tys.iter().map(|x| x.clean()).collect()),
743 TyPath(ref p, ref tpbs, id) => {
744 resolve_type(p.clean(),
745 tpbs.clean().map(|x| x.move_iter().collect()),
746 id)
747 }
748 TyClosure(ref c, region) => Closure(box c.clean(), region.clean()),
749 TyProc(ref c) => Proc(box c.clean()),
750 TyBareFn(ref barefn) => BareFunction(box barefn.clean()),
751 TyBot => Bottom,
752 ref x => fail!("Unimplemented type {:?}", x),
753 }
754 }
755 }
756
757 #[deriving(Clone, Encodable, Decodable)]
758 pub enum StructField {
759 HiddenStructField, // inserted later by strip passes
760 TypedStructField(Type),
761 }
762
763 impl Clean<Item> for ast::StructField {
764 fn clean(&self) -> Item {
765 let (name, vis) = match self.node.kind {
766 ast::NamedField(id, vis) => (Some(id), vis),
767 ast::UnnamedField(vis) => (None, vis)
768 };
769 Item {
770 name: name.clean(),
771 attrs: self.node.attrs.clean().move_iter().collect(),
772 source: self.span.clean(),
773 visibility: Some(vis),
774 id: self.node.id,
775 inner: StructFieldItem(TypedStructField(self.node.ty.clean())),
776 }
777 }
778 }
779
780 pub type Visibility = ast::Visibility;
781
782 impl Clean<Option<Visibility>> for ast::Visibility {
783 fn clean(&self) -> Option<Visibility> {
784 Some(*self)
785 }
786 }
787
788 #[deriving(Clone, Encodable, Decodable)]
789 pub struct Struct {
790 pub struct_type: doctree::StructType,
791 pub generics: Generics,
792 pub fields: Vec<Item>,
793 pub fields_stripped: bool,
794 }
795
796 impl Clean<Item> for doctree::Struct {
797 fn clean(&self) -> Item {
798 Item {
799 name: Some(self.name.clean()),
800 attrs: self.attrs.clean(),
801 source: self.where.clean(),
802 id: self.id,
803 visibility: self.vis.clean(),
804 inner: StructItem(Struct {
805 struct_type: self.struct_type,
806 generics: self.generics.clean(),
807 fields: self.fields.clean(),
808 fields_stripped: false,
809 }),
810 }
811 }
812 }
813
814 /// This is a more limited form of the standard Struct, different in that
815 /// it lacks the things most items have (name, id, parameterization). Found
816 /// only as a variant in an enum.
817 #[deriving(Clone, Encodable, Decodable)]
818 pub struct VariantStruct {
819 pub struct_type: doctree::StructType,
820 pub fields: Vec<Item>,
821 pub fields_stripped: bool,
822 }
823
824 impl Clean<VariantStruct> for syntax::ast::StructDef {
825 fn clean(&self) -> VariantStruct {
826 VariantStruct {
827 struct_type: doctree::struct_type_from_def(self),
828 fields: self.fields.clean().move_iter().collect(),
829 fields_stripped: false,
830 }
831 }
832 }
833
834 #[deriving(Clone, Encodable, Decodable)]
835 pub struct Enum {
836 pub variants: Vec<Item>,
837 pub generics: Generics,
838 pub variants_stripped: bool,
839 }
840
841 impl Clean<Item> for doctree::Enum {
842 fn clean(&self) -> Item {
843 Item {
844 name: Some(self.name.clean()),
845 attrs: self.attrs.clean(),
846 source: self.where.clean(),
847 id: self.id,
848 visibility: self.vis.clean(),
849 inner: EnumItem(Enum {
850 variants: self.variants.clean(),
851 generics: self.generics.clean(),
852 variants_stripped: false,
853 }),
854 }
855 }
856 }
857
858 #[deriving(Clone, Encodable, Decodable)]
859 pub struct Variant {
860 pub kind: VariantKind,
861 }
862
863 impl Clean<Item> for doctree::Variant {
864 fn clean(&self) -> Item {
865 Item {
866 name: Some(self.name.clean()),
867 attrs: self.attrs.clean(),
868 source: self.where.clean(),
869 visibility: self.vis.clean(),
870 id: self.id,
871 inner: VariantItem(Variant {
872 kind: self.kind.clean(),
873 }),
874 }
875 }
876 }
877
878 #[deriving(Clone, Encodable, Decodable)]
879 pub enum VariantKind {
880 CLikeVariant,
881 TupleVariant(Vec<Type>),
882 StructVariant(VariantStruct),
883 }
884
885 impl Clean<VariantKind> for ast::VariantKind {
886 fn clean(&self) -> VariantKind {
887 match self {
888 &ast::TupleVariantKind(ref args) => {
889 if args.len() == 0 {
890 CLikeVariant
891 } else {
892 TupleVariant(args.iter().map(|x| x.ty.clean()).collect())
893 }
894 },
895 &ast::StructVariantKind(ref sd) => StructVariant(sd.clean()),
896 }
897 }
898 }
899
900 #[deriving(Clone, Encodable, Decodable)]
901 pub struct Span {
902 pub filename: ~str,
903 pub loline: uint,
904 pub locol: uint,
905 pub hiline: uint,
906 pub hicol: uint,
907 }
908
909 impl Clean<Span> for syntax::codemap::Span {
910 fn clean(&self) -> Span {
911 let ctxt = super::ctxtkey.get().unwrap();
912 let cm = ctxt.sess().codemap();
913 let filename = cm.span_to_filename(*self);
914 let lo = cm.lookup_char_pos(self.lo);
915 let hi = cm.lookup_char_pos(self.hi);
916 Span {
917 filename: filename.to_owned(),
918 loline: lo.line,
919 locol: lo.col.to_uint(),
920 hiline: hi.line,
921 hicol: hi.col.to_uint(),
922 }
923 }
924 }
925
926 #[deriving(Clone, Encodable, Decodable)]
927 pub struct Path {
928 pub global: bool,
929 pub segments: Vec<PathSegment>,
930 }
931
932 impl Clean<Path> for ast::Path {
933 fn clean(&self) -> Path {
934 Path {
935 global: self.global,
936 segments: self.segments.clean().move_iter().collect(),
937 }
938 }
939 }
940
941 #[deriving(Clone, Encodable, Decodable)]
942 pub struct PathSegment {
943 pub name: ~str,
944 pub lifetimes: Vec<Lifetime>,
945 pub types: Vec<Type>,
946 }
947
948 impl Clean<PathSegment> for ast::PathSegment {
949 fn clean(&self) -> PathSegment {
950 PathSegment {
951 name: self.identifier.clean(),
952 lifetimes: self.lifetimes.clean().move_iter().collect(),
953 types: self.types.clean().move_iter().collect()
954 }
955 }
956 }
957
958 fn path_to_str(p: &ast::Path) -> ~str {
959 use syntax::parse::token;
960
961 let mut s = StrBuf::new();
962 let mut first = true;
963 for i in p.segments.iter().map(|x| token::get_ident(x.identifier)) {
964 if !first || p.global {
965 s.push_str("::");
966 } else {
967 first = false;
968 }
969 s.push_str(i.get());
970 }
971 s.into_owned()
972 }
973
974 impl Clean<~str> for ast::Ident {
975 fn clean(&self) -> ~str {
976 token::get_ident(*self).get().to_owned()
977 }
978 }
979
980 #[deriving(Clone, Encodable, Decodable)]
981 pub struct Typedef {
982 pub type_: Type,
983 pub generics: Generics,
984 }
985
986 impl Clean<Item> for doctree::Typedef {
987 fn clean(&self) -> Item {
988 Item {
989 name: Some(self.name.clean()),
990 attrs: self.attrs.clean(),
991 source: self.where.clean(),
992 id: self.id.clone(),
993 visibility: self.vis.clean(),
994 inner: TypedefItem(Typedef {
995 type_: self.ty.clean(),
996 generics: self.gen.clean(),
997 }),
998 }
999 }
1000 }
1001
1002 #[deriving(Clone, Encodable, Decodable)]
1003 pub struct BareFunctionDecl {
1004 pub fn_style: ast::FnStyle,
1005 pub generics: Generics,
1006 pub decl: FnDecl,
1007 pub abi: ~str,
1008 }
1009
1010 impl Clean<BareFunctionDecl> for ast::BareFnTy {
1011 fn clean(&self) -> BareFunctionDecl {
1012 BareFunctionDecl {
1013 fn_style: self.fn_style,
1014 generics: Generics {
1015 lifetimes: self.lifetimes.clean().move_iter().collect(),
1016 type_params: Vec::new(),
1017 },
1018 decl: self.decl.clean(),
1019 abi: self.abi.to_str(),
1020 }
1021 }
1022 }
1023
1024 #[deriving(Clone, Encodable, Decodable)]
1025 pub struct Static {
1026 pub type_: Type,
1027 pub mutability: Mutability,
1028 /// It's useful to have the value of a static documented, but I have no
1029 /// desire to represent expressions (that'd basically be all of the AST,
1030 /// which is huge!). So, have a string.
1031 pub expr: ~str,
1032 }
1033
1034 impl Clean<Item> for doctree::Static {
1035 fn clean(&self) -> Item {
1036 debug!("claning static {}: {:?}", self.name.clean(), self);
1037 Item {
1038 name: Some(self.name.clean()),
1039 attrs: self.attrs.clean(),
1040 source: self.where.clean(),
1041 id: self.id,
1042 visibility: self.vis.clean(),
1043 inner: StaticItem(Static {
1044 type_: self.type_.clean(),
1045 mutability: self.mutability.clean(),
1046 expr: self.expr.span.to_src(),
1047 }),
1048 }
1049 }
1050 }
1051
1052 #[deriving(Show, Clone, Encodable, Decodable)]
1053 pub enum Mutability {
1054 Mutable,
1055 Immutable,
1056 }
1057
1058 impl Clean<Mutability> for ast::Mutability {
1059 fn clean(&self) -> Mutability {
1060 match self {
1061 &ast::MutMutable => Mutable,
1062 &ast::MutImmutable => Immutable,
1063 }
1064 }
1065 }
1066
1067 #[deriving(Clone, Encodable, Decodable)]
1068 pub struct Impl {
1069 pub generics: Generics,
1070 pub trait_: Option<Type>,
1071 pub for_: Type,
1072 pub methods: Vec<Item>,
1073 pub derived: bool,
1074 }
1075
1076 impl Clean<Item> for doctree::Impl {
1077 fn clean(&self) -> Item {
1078 let mut derived = false;
1079 for attr in self.attrs.iter() {
1080 match attr.node.value.node {
1081 ast::MetaWord(ref s) => {
1082 if s.get() == "automatically_derived" {
1083 derived = true;
1084 }
1085 }
1086 _ => {}
1087 }
1088 }
1089 Item {
1090 name: None,
1091 attrs: self.attrs.clean(),
1092 source: self.where.clean(),
1093 id: self.id,
1094 visibility: self.vis.clean(),
1095 inner: ImplItem(Impl {
1096 generics: self.generics.clean(),
1097 trait_: self.trait_.clean(),
1098 for_: self.for_.clean(),
1099 methods: self.methods.clean(),
1100 derived: derived,
1101 }),
1102 }
1103 }
1104 }
1105
1106 #[deriving(Clone, Encodable, Decodable)]
1107 pub struct ViewItem {
1108 pub inner: ViewItemInner,
1109 }
1110
1111 impl Clean<Item> for ast::ViewItem {
1112 fn clean(&self) -> Item {
1113 Item {
1114 name: None,
1115 attrs: self.attrs.clean().move_iter().collect(),
1116 source: self.span.clean(),
1117 id: 0,
1118 visibility: self.vis.clean(),
1119 inner: ViewItemItem(ViewItem {
1120 inner: self.node.clean()
1121 }),
1122 }
1123 }
1124 }
1125
1126 #[deriving(Clone, Encodable, Decodable)]
1127 pub enum ViewItemInner {
1128 ExternCrate(~str, Option<~str>, ast::NodeId),
1129 Import(ViewPath)
1130 }
1131
1132 impl Clean<ViewItemInner> for ast::ViewItem_ {
1133 fn clean(&self) -> ViewItemInner {
1134 match self {
1135 &ast::ViewItemExternCrate(ref i, ref p, ref id) => {
1136 let string = match *p {
1137 None => None,
1138 Some((ref x, _)) => Some(x.get().to_owned()),
1139 };
1140 ExternCrate(i.clean(), string, *id)
1141 }
1142 &ast::ViewItemUse(ref vp) => {
1143 Import(vp.clean())
1144 }
1145 }
1146 }
1147 }
1148
1149 #[deriving(Clone, Encodable, Decodable)]
1150 pub enum ViewPath {
1151 // use str = source;
1152 SimpleImport(~str, ImportSource),
1153 // use source::*;
1154 GlobImport(ImportSource),
1155 // use source::{a, b, c};
1156 ImportList(ImportSource, Vec<ViewListIdent> ),
1157 }
1158
1159 #[deriving(Clone, Encodable, Decodable)]
1160 pub struct ImportSource {
1161 pub path: Path,
1162 pub did: Option<ast::DefId>,
1163 }
1164
1165 impl Clean<ViewPath> for ast::ViewPath {
1166 fn clean(&self) -> ViewPath {
1167 match self.node {
1168 ast::ViewPathSimple(ref i, ref p, id) =>
1169 SimpleImport(i.clean(), resolve_use_source(p.clean(), id)),
1170 ast::ViewPathGlob(ref p, id) =>
1171 GlobImport(resolve_use_source(p.clean(), id)),
1172 ast::ViewPathList(ref p, ref pl, id) => {
1173 ImportList(resolve_use_source(p.clean(), id),
1174 pl.clean().move_iter().collect())
1175 }
1176 }
1177 }
1178 }
1179
1180 #[deriving(Clone, Encodable, Decodable)]
1181 pub struct ViewListIdent {
1182 pub name: ~str,
1183 pub source: Option<ast::DefId>,
1184 }
1185
1186 impl Clean<ViewListIdent> for ast::PathListIdent {
1187 fn clean(&self) -> ViewListIdent {
1188 ViewListIdent {
1189 name: self.node.name.clean(),
1190 source: resolve_def(self.node.id),
1191 }
1192 }
1193 }
1194
1195 impl Clean<Vec<Item>> for ast::ForeignMod {
1196 fn clean(&self) -> Vec<Item> {
1197 self.items.clean()
1198 }
1199 }
1200
1201 impl Clean<Item> for ast::ForeignItem {
1202 fn clean(&self) -> Item {
1203 let inner = match self.node {
1204 ast::ForeignItemFn(ref decl, ref generics) => {
1205 ForeignFunctionItem(Function {
1206 decl: decl.clean(),
1207 generics: generics.clean(),
1208 fn_style: ast::NormalFn,
1209 })
1210 }
1211 ast::ForeignItemStatic(ref ty, mutbl) => {
1212 ForeignStaticItem(Static {
1213 type_: ty.clean(),
1214 mutability: if mutbl {Mutable} else {Immutable},
1215 expr: "".to_owned(),
1216 })
1217 }
1218 };
1219 Item {
1220 name: Some(self.ident.clean()),
1221 attrs: self.attrs.clean().move_iter().collect(),
1222 source: self.span.clean(),
1223 id: self.id,
1224 visibility: self.vis.clean(),
1225 inner: inner,
1226 }
1227 }
1228 }
1229
1230 // Utilities
1231
1232 trait ToSource {
1233 fn to_src(&self) -> ~str;
1234 }
1235
1236 impl ToSource for syntax::codemap::Span {
1237 fn to_src(&self) -> ~str {
1238 debug!("converting span {:?} to snippet", self.clean());
1239 let ctxt = super::ctxtkey.get().unwrap();
1240 let cm = ctxt.sess().codemap().clone();
1241 let sn = match cm.span_to_snippet(*self) {
1242 Some(x) => x.to_owned(),
1243 None => "".to_owned()
1244 };
1245 debug!("got snippet {}", sn);
1246 sn
1247 }
1248 }
1249
1250 fn lit_to_str(lit: &ast::Lit) -> ~str {
1251 match lit.node {
1252 ast::LitStr(ref st, _) => st.get().to_owned(),
1253 ast::LitBinary(ref data) => format!("{:?}", data.as_slice()),
1254 ast::LitChar(c) => format!("'{}'", c),
1255 ast::LitInt(i, _t) => i.to_str(),
1256 ast::LitUint(u, _t) => u.to_str(),
1257 ast::LitIntUnsuffixed(i) => i.to_str(),
1258 ast::LitFloat(ref f, _t) => f.get().to_str(),
1259 ast::LitFloatUnsuffixed(ref f) => f.get().to_str(),
1260 ast::LitBool(b) => b.to_str(),
1261 ast::LitNil => "".to_owned(),
1262 }
1263 }
1264
1265 fn name_from_pat(p: &ast::Pat) -> ~str {
1266 use syntax::ast::*;
1267 debug!("Trying to get a name from pattern: {:?}", p);
1268
1269 match p.node {
1270 PatWild => "_".to_owned(),
1271 PatWildMulti => "..".to_owned(),
1272 PatIdent(_, ref p, _) => path_to_str(p),
1273 PatEnum(ref p, _) => path_to_str(p),
1274 PatStruct(..) => fail!("tried to get argument name from pat_struct, \
1275 which is not allowed in function arguments"),
1276 PatTup(..) => "(tuple arg NYI)".to_owned(),
1277 PatUniq(p) => name_from_pat(p),
1278 PatRegion(p) => name_from_pat(p),
1279 PatLit(..) => {
1280 warn!("tried to get argument name from PatLit, \
1281 which is silly in function arguments");
1282 "()".to_owned()
1283 },
1284 PatRange(..) => fail!("tried to get argument name from PatRange, \
1285 which is not allowed in function arguments"),
1286 PatVec(..) => fail!("tried to get argument name from pat_vec, \
1287 which is not allowed in function arguments")
1288 }
1289 }
1290
1291 /// Given a Type, resolve it using the def_map
1292 fn resolve_type(path: Path, tpbs: Option<Vec<TyParamBound> >,
1293 id: ast::NodeId) -> Type {
1294 let cx = super::ctxtkey.get().unwrap();
1295 let tycx = match cx.maybe_typed {
1296 core::Typed(ref tycx) => tycx,
1297 // If we're extracting tests, this return value doesn't matter.
1298 core::NotTyped(_) => return Bool
1299 };
1300 debug!("searching for {:?} in defmap", id);
1301 let d = match tycx.def_map.borrow().find(&id) {
1302 Some(&k) => k,
1303 None => {
1304 debug!("could not find {:?} in defmap (`{}`)", id, tycx.map.node_to_str(id));
1305 fail!("Unexpected failure: unresolved id not in defmap (this is a bug!)")
1306 }
1307 };
1308
1309 let (def_id, kind) = match d {
1310 ast::DefFn(i, _) => (i, TypeFunction),
1311 ast::DefSelfTy(i) => return Self(i),
1312 ast::DefTy(i) => (i, TypeEnum),
1313 ast::DefTrait(i) => {
1314 debug!("saw DefTrait in def_to_id");
1315 (i, TypeTrait)
1316 },
1317 ast::DefPrimTy(p) => match p {
1318 ast::TyStr => return String,
1319 ast::TyBool => return Bool,
1320 _ => return Primitive(p)
1321 },
1322 ast::DefTyParam(i, _) => return Generic(i.node),
1323 ast::DefStruct(i) => (i, TypeStruct),
1324 ast::DefTyParamBinder(i) => {
1325 debug!("found a typaram_binder, what is it? {}", i);
1326 return TyParamBinder(i);
1327 },
1328 x => fail!("resolved type maps to a weird def {:?}", x),
1329 };
1330 if ast_util::is_local(def_id) {
1331 ResolvedPath{ path: path, typarams: tpbs, id: def_id.node }
1332 } else {
1333 let fqn = csearch::get_item_path(tycx, def_id);
1334 let fqn = fqn.move_iter().map(|i| i.to_str()).collect();
1335 ExternalPath {
1336 path: path,
1337 typarams: tpbs,
1338 fqn: fqn,
1339 kind: kind,
1340 krate: def_id.krate,
1341 }
1342 }
1343 }
1344
1345 fn resolve_use_source(path: Path, id: ast::NodeId) -> ImportSource {
1346 ImportSource {
1347 path: path,
1348 did: resolve_def(id),
1349 }
1350 }
1351
1352 fn resolve_def(id: ast::NodeId) -> Option<ast::DefId> {
1353 let cx = super::ctxtkey.get().unwrap();
1354 match cx.maybe_typed {
1355 core::Typed(ref tcx) => {
1356 tcx.def_map.borrow().find(&id).map(|&d| ast_util::def_id_of_def(d))
1357 }
1358 core::NotTyped(_) => None
1359 }
1360 }
1361
1362 #[deriving(Clone, Encodable, Decodable)]
1363 pub struct Macro {
1364 pub source: ~str,
1365 }
1366
1367 impl Clean<Item> for doctree::Macro {
1368 fn clean(&self) -> Item {
1369 Item {
1370 name: Some(self.name.clean() + "!"),
1371 attrs: self.attrs.clean(),
1372 source: self.where.clean(),
1373 visibility: ast::Public.clean(),
1374 id: self.id,
1375 inner: MacroItem(Macro {
1376 source: self.where.to_src(),
1377 }),
1378 }
1379 }
1380 }
librustdoc/clean.rs:716:41-716:41 -enum- definition:
pub enum TypeKind {
TypeStruct,
TypeEnum,
references:- 7717: pub enum TypeKind {
librustdoc/html/format.rs:
163: fn external_path(w: &mut io::Writer, p: &clean::Path, print_all: bool,
164: fqn: &[~str], kind: clean::TypeKind,
165: krate: ast::CrateNum) -> fmt::Result {
librustdoc/clean.rs:
717: pub enum TypeKind {
librustdoc/clean.rs:926:41-926:41 -struct- definition:
pub struct Path {
pub global: bool,
pub segments: Vec<PathSegment>,
references:- 22927: pub struct Path {
--
933: fn clean(&self) -> Path {
934: Path {
935: global: self.global,
librustdoc/html/format.rs:
567: Some(did) if ast_util::is_local(did) => {
568: let path = clean::Path {
569: global: false,
librustdoc/clean.rs:
932: impl Clean<Path> for ast::Path {
933: fn clean(&self) -> Path {
--
1160: pub struct ImportSource {
1161: pub path: Path,
1162: pub did: Option<ast::DefId>,
--
1291: /// Given a Type, resolve it using the def_map
1292: fn resolve_type(path: Path, tpbs: Option<Vec<TyParamBound> >,
1293: id: ast::NodeId) -> Type {
--
1345: fn resolve_use_source(path: Path, id: ast::NodeId) -> ImportSource {
1346: ImportSource {
librustdoc/html/format.rs:
112: impl fmt::Show for clean::Path {
113: fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
--
148: /// rendering function with the necessary arguments for linking to a local path.
149: fn resolved_path(w: &mut io::Writer, id: ast::NodeId, p: &clean::Path,
150: print_all: bool) -> fmt::Result {
--
162: /// will invoke `path` with proper linking-style arguments.
163: fn external_path(w: &mut io::Writer, p: &clean::Path, print_all: bool,
164: fqn: &[~str], kind: clean::TypeKind,
--
184: fn path(w: &mut io::Writer, path: &clean::Path, print_all: bool,
185: root: |&render::Cache, &[~str]| -> Option<~str>,
librustdoc/clean.rs:
932: impl Clean<Path> for ast::Path {
933: fn clean(&self) -> Path {
934: Path {
librustdoc/clean.rs:1052:47-1052:47 -enum- definition:
pub enum Mutability {
Mutable,
Immutable,
references:- 121053: pub enum Mutability {
--
1058: impl Clean<Mutability> for ast::Mutability {
1059: fn clean(&self) -> Mutability {
1060: match self {
librustdoc/clean.rs:598:41-598:41 -struct- definition:
pub struct Trait {
pub methods: Vec<TraitMethod>,
pub generics: Generics,
references:- 13599: pub struct Trait {
--
612: visibility: self.vis.clean(),
613: inner: TraitItem(Trait {
614: methods: self.methods.clean(),
librustdoc/html/render.rs:
1224: fn item_trait(w: &mut Writer, it: &clean::Item,
1225: t: &clean::Trait) -> fmt::Result {
1226: let mut parents = StrBuf::new();
librustdoc/clean.rs:941:41-941:41 -struct- definition:
pub struct PathSegment {
pub name: ~str,
pub lifetimes: Vec<Lifetime>,
references:- 14949: fn clean(&self) -> PathSegment {
950: PathSegment {
951: name: self.identifier.clean(),
librustdoc/html/format.rs:
569: global: false,
570: segments: vec!(clean::PathSegment {
571: name: self.name.clone(),
librustdoc/clean.rs:
942: pub struct PathSegment {
--
948: impl Clean<PathSegment> for ast::PathSegment {
949: fn clean(&self) -> PathSegment {
950: PathSegment {
librustdoc/clean.rs:858:41-858:41 -struct- definition:
pub struct Variant {
pub kind: VariantKind,
}
references:- 12870: id: self.id,
871: inner: VariantItem(Variant {
872: kind: self.kind.clean(),
librustdoc/fold.rs:
76: j.fields_stripped |= num_fields != j.fields.len();
77: VariantItem(Variant {kind: StructVariant(j), ..i2})
78: },
librustdoc/clean.rs:
859: pub struct Variant {
librustdoc/clean.rs:1344:1-1344:1 -fn- definition:
fn resolve_use_source(path: Path, id: ast::NodeId) -> ImportSource {
ImportSource {
path: path,
references:- 31168: ast::ViewPathSimple(ref i, ref p, id) =>
1169: SimpleImport(i.clean(), resolve_use_source(p.clean(), id)),
1170: ast::ViewPathGlob(ref p, id) =>
--
1172: ast::ViewPathList(ref p, ref pl, id) => {
1173: ImportList(resolve_use_source(p.clean(), id),
1174: pl.clean().move_iter().collect())
librustdoc/clean.rs:70:41-70:41 -struct- definition:
pub struct Crate {
pub name: ~str,
pub module: Option<Item>,
references:- 2871: pub struct Crate {
--
93: t_outputs.out_filestem);
94: Crate {
95: name: id.name.to_owned(),
librustdoc/core.rs:
107: pub fn run_core(libs: HashSet<Path>, cfgs: Vec<~str>, path: &Path)
108: -> (clean::Crate, CrateAnalysis) {
109: let (ctxt, analysis) = get_ast_and_resolve(path, libs, cfgs);
librustdoc/fold.rs:
96: fn fold_crate(&mut self, mut c: Crate) -> Crate {
97: c.module = match replace(&mut c.module, None) {
librustdoc/html/render.rs:
208: /// Generates the documentation for `crate` into the directory `dst`
209: pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> {
210: let mut cx = Context {
--
825: /// parallelization to this function.
826: fn krate(self, mut krate: clean::Crate, cache: Cache) -> io::IoResult<()> {
827: let mut item = match krate.module.take() {
librustdoc/passes.rs:
242: pub fn collapse_docs(krate: clean::Crate) -> plugins::PluginResult {
243: struct Collapser;
librustdoc/plugins.rs:
17: pub type PluginJson = Option<(~str, json::Json)>;
18: pub type PluginResult = (clean::Crate, PluginJson);
19: pub type PluginCallback = fn (clean::Crate) -> PluginResult;
--
60: /// Run all the loaded plugins over the crate, returning their results
61: pub fn run_plugins(&self, krate: clean::Crate) -> (clean::Crate, Vec<PluginJson> ) {
62: let mut out_json = Vec::new();
librustdoc/lib.rs:
60: type Pass = (&'static str, // name
61: fn(clean::Crate) -> plugins::PluginResult, // fn
62: &'static str); // description
--
373: /// destination.
374: fn json_output(krate: clean::Crate, res: Vec<plugins::PluginJson> ,
375: dst: Path) -> io::IoResult<()> {
librustdoc/clean.rs:
71: pub struct Crate {
librustdoc/clean.rs:1126:41-1126:41 -enum- definition:
pub enum ViewItemInner {
ExternCrate(~str, Option<~str>, ast::NodeId),
Import(ViewPath)
references:- 81127: pub enum ViewItemInner {
--
1132: impl Clean<ViewItemInner> for ast::ViewItem_ {
1133: fn clean(&self) -> ViewItemInner {
1134: match self {
librustdoc/clean.rs:122:41-122:41 -struct- definition:
pub struct Item {
/// Stringified span
pub source: Span,
references:- 122librustdoc/fold.rs:
librustdoc/passes.rs:
librustdoc/clean.rs:
librustdoc/fold.rs:
librustdoc/html/item_type.rs:
librustdoc/html/render.rs:
librustdoc/passes.rs:
librustdoc/test.rs:
librustdoc/clean.rs:
librustdoc/clean.rs:348:41-348:41 -enum- definition:
pub enum TyParamBound {
RegionBound,
TraitBound(Type)
references:- 14349: pub enum TyParamBound {
--
671: pub path: Path,
672: pub typarams: Option<Vec<TyParamBound>>,
673: pub id: ast::NodeId,
--
677: pub path: Path,
678: pub typarams: Option<Vec<TyParamBound>>,
679: pub fqn: Vec<~str>,
--
1291: /// Given a Type, resolve it using the def_map
1292: fn resolve_type(path: Path, tpbs: Option<Vec<TyParamBound> >,
1293: id: ast::NodeId) -> Type {
librustdoc/html/format.rs:
277: fn tybounds(w: &mut io::Writer,
278: typarams: &Option<Vec<clean::TyParamBound> >) -> fmt::Result {
279: match *typarams {
librustdoc/clean.rs:
521: pub fn_style: ast::FnStyle,
522: pub bounds: Vec<TyParamBound>,
523: }
librustdoc/clean.rs:217:41-217:41 -struct- definition:
pub struct Module {
pub items: Vec<Item>,
pub is_crate: bool,
references:- 15271: id: self.id,
272: inner: ModuleItem(Module {
273: is_crate: self.is_crate,
librustdoc/fold.rs:
89: fn fold_mod(&mut self, m: Module) -> Module {
90: Module {
91: is_crate: m.is_crate,
librustdoc/clean.rs:
195: FunctionItem(Function),
196: ModuleItem(Module),
197: TypedefItem(Typedef),
--
218: pub struct Module {
librustdoc/fold.rs:
89: fn fold_mod(&mut self, m: Module) -> Module {
90: Module {
librustdoc/html/render.rs:
1727: fn build_sidebar(m: &clean::Module) -> HashMap<~str, Vec<~str> > {
1728: let mut map = HashMap::new();
librustdoc/clean.rs:
218: pub struct Module {
librustdoc/clean.rs:548:41-548:41 -struct- definition:
pub struct Arguments {
pub values: Vec<Argument>,
}
references:- 14449: let decl = FnDecl {
450: inputs: Arguments {
451: values: inputs.iter().map(|x| x.clean()).collect(),
--
549: pub struct Arguments {
--
555: FnDecl {
556: inputs: Arguments {
557: values: self.inputs.iter().map(|x| x.clean()).collect(),
librustdoc/html/format.rs:
440: impl fmt::Show for clean::Arguments {
441: fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
librustdoc/clean.rs:
549: pub struct Arguments {
librustdoc/clean.rs:364:41-364:41 -struct- definition:
pub struct Lifetime(~str);
impl Lifetime {
pub fn get_ref<'a>(&'a self) -> &'a str {
references:- 15375: impl Clean<Lifetime> for ast::Lifetime {
376: fn clean(&self) -> Lifetime {
377: Lifetime(token::get_name(self.name).get().to_owned())
--
708: BorrowedRef {
709: pub lifetime: Option<Lifetime>,
710: pub mutability: Mutability,
--
943: pub name: ~str,
944: pub lifetimes: Vec<Lifetime>,
945: pub types: Vec<Type>,
librustdoc/html/format.rs:
91: impl fmt::Show for clean::Lifetime {
92: fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
librustdoc/clean.rs:
365: pub struct Lifetime(~str);
librustdoc/clean.rs:757:41-757:41 -enum- definition:
pub enum StructField {
HiddenStructField, // inserted later by strip passes
TypedStructField(Type),
references:- 6758: pub enum StructField {
librustdoc/clean.rs:583:41-583:41 -enum- definition:
pub enum RetStyle {
NoReturn,
Return
references:- 8584: pub enum RetStyle {
--
589: impl Clean<RetStyle> for ast::RetStyle {
590: fn clean(&self) -> RetStyle {
591: match *self {
librustdoc/clean.rs:834:41-834:41 -struct- definition:
pub struct Enum {
pub variants: Vec<Item>,
pub generics: Generics,
references:- 12835: pub struct Enum {
--
848: visibility: self.vis.clean(),
849: inner: EnumItem(Enum {
850: variants: self.variants.clean(),
librustdoc/html/render.rs:
1387: fn item_enum(w: &mut Writer, it: &clean::Item, e: &clean::Enum) -> fmt::Result {
1388: try!(write!(w, "<pre class='rust enum'>{}enum {}{}",
librustdoc/clean.rs:
835: pub struct Enum {
librustdoc/clean.rs:566:41-566:41 -struct- definition:
pub struct Argument {
pub type_: Type,
pub name: ~str,
references:- 13574: fn clean(&self) -> Argument {
575: Argument {
576: name: name_from_pat(self.pat),
librustdoc/clean.rs:1149:41-1149:41 -enum- definition:
pub enum ViewPath {
// use str = source;
SimpleImport(~str, ImportSource),
references:- 91165: impl Clean<ViewPath> for ast::ViewPath {
1166: fn clean(&self) -> ViewPath {
1167: match self.node {
librustdoc/html/format.rs:
516: impl fmt::Show for clean::ViewPath {
517: fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
librustdoc/clean.rs:
1165: impl Clean<ViewPath> for ast::ViewPath {
1166: fn clean(&self) -> ViewPath {
librustdoc/clean.rs:957:1-957:1 -fn- definition:
fn path_to_str(p: &ast::Path) -> ~str {
use syntax::parse::token;
let mut s = StrBuf::new();
references:- 21271: PatWildMulti => "..".to_owned(),
1272: PatIdent(_, ref p, _) => path_to_str(p),
1273: PatEnum(ref p, _) => path_to_str(p),
1274: PatStruct(..) => fail!("tried to get argument name from pat_struct, \
librustdoc/clean.rs:1106:41-1106:41 -struct- definition:
pub struct ViewItem {
pub inner: ViewItemInner,
}
references:- 111118: visibility: self.vis.clean(),
1119: inner: ViewItemItem(ViewItem {
1120: inner: self.node.clean()
librustdoc/clean.rs:1024:41-1024:41 -struct- definition:
pub struct Static {
pub type_: Type,
pub mutability: Mutability,
references:- 131025: pub struct Static {
--
1042: visibility: self.vis.clean(),
1043: inner: StaticItem(Static {
1044: type_: self.type_.clean(),
--
1211: ast::ForeignItemStatic(ref ty, mutbl) => {
1212: ForeignStaticItem(Static {
1213: type_: ty.clean(),
librustdoc/clean.rs:667:41-667:41 -enum- definition:
pub enum Type {
/// structs/enums/traits (anything that'd be an ast::TyPath)
ResolvedPath {
references:- 32librustdoc/html/format.rs:
librustdoc/html/render.rs:
librustdoc/clean.rs:
librustdoc/clean.rs:1264:1-1264:1 -fn- definition:
fn name_from_pat(p: &ast::Pat) -> ~str {
use syntax::ast::*;
debug!("Trying to get a name from pattern: {:?}", p);
references:- 31277: PatUniq(p) => name_from_pat(p),
1278: PatRegion(p) => name_from_pat(p),
1279: PatLit(..) => {
librustdoc/clean.rs:1067:41-1067:41 -struct- definition:
pub struct Impl {
pub generics: Generics,
pub trait_: Option<Type>,
references:- 171068: pub struct Impl {
--
1094: visibility: self.vis.clean(),
1095: inner: ImplItem(Impl {
1096: generics: self.generics.clean(),
librustdoc/html/render.rs:
1552: });
1553: let non_trait = non_trait.collect::<Vec<&(clean::Impl, Option<~str>)>>();
1554: let mut traits = v.iter().filter(|p| {
--
1592: fn render_impl(w: &mut Writer, i: &clean::Impl,
1593: dox: &Option<~str>) -> fmt::Result {
librustdoc/passes.rs:
67: match i.inner {
68: clean::ImplItem(clean::Impl{ for_: clean::ResolvedPath{ id: for_id, .. },
69: .. }) => {
--
148: // trait impls for private items should be stripped
149: clean::ImplItem(clean::Impl{ for_: clean::ResolvedPath{ id: ref for_id, .. }, .. }) => {
150: if !self.exported_items.contains(for_id) {
librustdoc/clean.rs:
1068: pub struct Impl {
librustdoc/clean.rs:282:41-282:41 -enum- definition:
pub enum Attribute {
Word(~str),
List(~str, Vec<Attribute> ),
references:- 17289: impl Clean<Attribute> for ast::MetaItem {
290: fn clean(&self) -> Attribute {
--
303: impl Clean<Attribute> for ast::Attribute {
304: fn clean(&self) -> Attribute {
305: self.desugar_doc().node.value.clean()
--
544: pub cf: RetStyle,
545: pub attrs: Vec<Attribute>,
546: }
librustdoc/passes.rs:
256: }
257: let mut a: Vec<clean::Attribute> = i.attrs.iter().filter(|&a| match a {
258: &clean::NameValue(ref x, _) if "doc" == *x => false,
librustdoc/clean.rs:
283: pub enum Attribute {
librustdoc/clean.rs:1180:41-1180:41 -struct- definition:
pub struct ViewListIdent {
pub name: ~str,
pub source: Option<ast::DefId>,
references:- 141181: pub struct ViewListIdent {
--
1187: fn clean(&self) -> ViewListIdent {
1188: ViewListIdent {
1189: name: self.node.name.clean(),
librustdoc/html/format.rs:
563: impl fmt::Show for clean::ViewListIdent {
564: fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
librustdoc/clean.rs:
1181: pub struct ViewListIdent {
librustdoc/clean.rs:878:41-878:41 -enum- definition:
pub enum VariantKind {
CLikeVariant,
TupleVariant(Vec<Type>),
references:- 8885: impl Clean<VariantKind> for ast::VariantKind {
886: fn clean(&self) -> VariantKind {
887: match self {
librustdoc/clean.rs:628:41-628:41 -enum- definition:
pub enum TraitMethod {
Required(Item),
Provided(Item),
references:- 14634: impl TraitMethod {
635: pub fn is_req(&self) -> bool {
--
655: impl Clean<TraitMethod> for ast::TraitMethod {
656: fn clean(&self) -> TraitMethod {
657: match self {
librustdoc/fold.rs:
42: TraitItem(mut i) => {
43: fn vtrm<T: DocFolder>(this: &mut T, trm: TraitMethod) -> Option<TraitMethod> {
44: match trm {
librustdoc/html/render.rs:
1240: parents));
1241: let required = t.methods.iter().filter(|m| m.is_req()).collect::<Vec<&clean::TraitMethod>>();
1242: let provided = t.methods.iter().filter(|m| !m.is_req()).collect::<Vec<&clean::TraitMethod>>();
--
1268: fn meth(w: &mut Writer, m: &clean::TraitMethod) -> fmt::Result {
1269: try!(write!(w, "<h3 id='{}.{}' class='method'><code>",
librustdoc/clean.rs:
629: pub enum TraitMethod {
librustdoc/clean.rs:382:41-382:41 -struct- definition:
pub struct Generics {
pub lifetimes: Vec<Lifetime>,
pub type_params: Vec<TyParam>,
references:- 271013: fn_style: self.fn_style,
1014: generics: Generics {
1015: lifetimes: self.lifetimes.clean().move_iter().collect(),
--
1068: pub struct Impl {
1069: pub generics: Generics,
1070: pub trait_: Option<Type>,
librustdoc/html/format.rs:
52: impl fmt::Show for clean::Generics {
53: fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
librustdoc/html/render.rs:
109: /// primitive types and otherwise non-path types.
110: OtherType(clean::Generics, /* trait */ clean::Type, /* for */ clean::Type),
111: }
--
786: impl<'a> Cache {
787: fn generics(&mut self, generics: &clean::Generics) {
788: for typ in generics.type_params.iter() {
--
1483: fn render_struct(w: &mut Writer, it: &clean::Item,
1484: g: Option<&clean::Generics>,
1485: ty: doctree::StructType,
librustdoc/clean.rs:
438: pub decl: FnDecl,
439: pub generics: Generics,
440: pub self_: SelfTy,
librustdoc/clean.rs:1291:47-1291:47 -fn- definition:
/// Given a Type, resolve it using the def_map
fn resolve_type(path: Path, tpbs: Option<Vec<TyParamBound> >,
id: ast::NodeId) -> Type {
references:- 2623: fn clean(&self) -> Type {
624: resolve_type(self.path.clean(), None, self.ref_id)
625: }
--
743: TyPath(ref p, ref tpbs, id) => {
744: resolve_type(p.clean(),
745: tpbs.clean().map(|x| x.move_iter().collect()),
librustdoc/clean.rs:397:41-397:41 -struct- definition:
pub struct Method {
pub generics: Generics,
pub self_: SelfTy,
references:- 11398: pub struct Method {
--
424: visibility: self.vis.clean(),
425: inner: MethodItem(Method {
426: generics: self.generics.clean(),
librustdoc/clean.rs:492:41-492:41 -struct- definition:
pub struct Function {
pub decl: FnDecl,
pub generics: Generics,
references:- 141204: ast::ForeignItemFn(ref decl, ref generics) => {
1205: ForeignFunctionItem(Function {
1206: decl: decl.clean(),
librustdoc/html/render.rs:
1212: fn item_function(w: &mut Writer, it: &clean::Item,
1213: f: &clean::Function) -> fmt::Result {
1214: try!(write!(w, "<pre class='rust fn'>{vis}{fn_style}fn \
librustdoc/clean.rs:
493: pub struct Function {
librustdoc/clean.rs:788:41-788:41 -struct- definition:
pub struct Struct {
pub struct_type: doctree::StructType,
pub generics: Generics,
references:- 12789: pub struct Struct {
--
803: visibility: self.vis.clean(),
804: inner: StructItem(Struct {
805: struct_type: self.struct_type,
librustdoc/html/render.rs:
1350: fn item_struct(w: &mut Writer, it: &clean::Item,
1351: s: &clean::Struct) -> fmt::Result {
1352: try!(write!(w, "<pre class='rust struct'>"));
librustdoc/clean.rs:
192: pub enum ItemEnum {
193: StructItem(Struct),
194: EnumItem(Enum),
librustdoc/clean.rs:516:41-516:41 -struct- definition:
pub struct ClosureDecl {
pub lifetimes: Vec<Lifetime>,
pub decl: FnDecl,
references:- 14517: pub struct ClosureDecl {
--
526: fn clean(&self) -> ClosureDecl {
527: ClosureDecl {
528: lifetimes: self.lifetimes.clean().move_iter().collect(),
--
692: Closure(Box<ClosureDecl>, Option<Lifetime>),
693: Proc(Box<ClosureDecl>),
694: /// extern "ABI" fn
librustdoc/clean.rs:1362:41-1362:41 -struct- definition:
pub struct Macro {
pub source: ~str,
}
references:- 121374: id: self.id,
1375: inner: MacroItem(Macro {
1376: source: self.where.to_src(),
librustdoc/html/render.rs:
1765: fn item_macro(w: &mut Writer, it: &clean::Item,
1766: t: &clean::Macro) -> fmt::Result {
1767: try!(w.write_str(highlight::highlight(t.source, Some("macro"))));
librustdoc/clean.rs:
1363: pub struct Macro {
librustdoc/clean.rs:779:1-779:1 -NK_AS_STR_TODO- definition:
pub type Visibility = ast::Visibility;
impl Clean<Option<Visibility>> for ast::Visibility {
fn clean(&self) -> Option<Visibility> {
references:- 3782: impl Clean<Option<Visibility>> for ast::Visibility {
783: fn clean(&self) -> Option<Visibility> {
784: Some(*self)
librustdoc/clean.rs:817:41-817:41 -struct- definition:
pub struct VariantStruct {
pub struct_type: doctree::StructType,
pub fields: Vec<Item>,
references:- 13816: /// only as a variant in an enum.
818: pub struct VariantStruct {
--
825: fn clean(&self) -> VariantStruct {
826: VariantStruct {
827: struct_type: doctree::struct_type_from_def(self),
--
881: TupleVariant(Vec<Type>),
882: StructVariant(VariantStruct),
883: }
librustdoc/clean.rs:1002:41-1002:41 -struct- definition:
pub struct BareFunctionDecl {
pub fn_style: ast::FnStyle,
pub generics: Generics,
references:- 131003: pub struct BareFunctionDecl {
--
1011: fn clean(&self) -> BareFunctionDecl {
1012: BareFunctionDecl {
1013: fn_style: self.fn_style,
librustdoc/clean.rs:540:41-540:41 -struct- definition:
pub struct FnDecl {
pub inputs: Arguments,
pub output: Type,
references:- 22541: pub struct FnDecl {
--
554: fn clean(&self) -> FnDecl {
555: FnDecl {
556: inputs: Arguments {
--
1005: pub generics: Generics,
1006: pub decl: FnDecl,
1007: pub abi: ~str,
librustdoc/html/format.rs:
453: impl fmt::Show for clean::FnDecl {
454: fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
librustdoc/html/render.rs:
1326: g: &clean::Generics, selfty: &clean::SelfTy,
1327: d: &clean::FnDecl) -> fmt::Result {
1328: write!(w, "{}fn <a href='\\#{ty}.{name}' class='fnname'>{name}</a>\
librustdoc/clean.rs:
401: pub fn_style: ast::FnStyle,
402: pub decl: FnDecl,
403: }
librustdoc/clean.rs:1351:1-1351:1 -fn- definition:
fn resolve_def(id: ast::NodeId) -> Option<ast::DefId> {
let cx = super::ctxtkey.get().unwrap();
match cx.maybe_typed {
references:- 21347: path: path,
1348: did: resolve_def(id),
1349: }
librustdoc/clean.rs:38:1-38:1 -trait- definition:
pub trait Clean<T> {
fn clean(&self) -> T;
}
references:- 52librustdoc/clean.rs:473:41-473:41 -enum- definition:
pub enum SelfTy {
SelfStatic,
SelfValue,
references:- 11474: pub enum SelfTy {
--
481: impl Clean<SelfTy> for ast::ExplicitSelf {
482: fn clean(&self) -> SelfTy {
483: match self.node {
librustdoc/html/format.rs:
37: /// Wrapper struct for properly emitting a method declaration.
38: pub struct Method<'a>(pub &'a clean::SelfTy, pub &'a clean::FnDecl);
librustdoc/html/render.rs:
1325: fn fun(w: &mut Writer, it: &clean::Item, fn_style: ast::FnStyle,
1326: g: &clean::Generics, selfty: &clean::SelfTy,
1327: d: &clean::FnDecl) -> fmt::Result {
librustdoc/clean.rs:
474: pub enum SelfTy {
librustdoc/clean.rs:435:41-435:41 -struct- definition:
pub struct TyMethod {
pub fn_style: ast::FnStyle,
pub decl: FnDecl,
references:- 11462: visibility: None,
463: inner: TyMethodItem(TyMethod {
464: fn_style: self.fn_style.clone(),
librustdoc/clean.rs:191:41-191:41 -enum- definition:
pub enum ItemEnum {
StructItem(Struct),
EnumItem(Enum),
references:- 6192: pub enum ItemEnum {
librustdoc/clean.rs:980:41-980:41 -struct- definition:
pub struct Typedef {
pub type_: Type,
pub generics: Generics,
references:- 12993: visibility: self.vis.clean(),
994: inner: TypedefItem(Typedef {
995: type_: self.ty.clean(),
librustdoc/html/render.rs:
1662: fn item_typedef(w: &mut Writer, it: &clean::Item,
1663: t: &clean::Typedef) -> fmt::Result {
1664: try!(write!(w, "<pre class='rust typedef'>type {}{} = {};</pre>",
librustdoc/clean.rs:
981: pub struct Typedef {
librustdoc/clean.rs:102:41-102:41 -struct- definition:
pub struct ExternalCrate {
pub name: ~str,
pub attrs: Vec<Attribute>,
references:- 14109: fn clean(&self) -> ExternalCrate {
110: ExternalCrate {
111: name: self.name.to_owned(),
librustdoc/html/render.rs:
457: /// rendering in to the specified source destination.
458: fn extern_location(e: &clean::ExternalCrate, dst: &Path) -> ExternalLocation {
459: // See if there's documentation generated into the local directory
librustdoc/clean.rs:
103: pub struct ExternalCrate {
librustdoc/clean.rs:331:41-331:41 -struct- definition:
pub struct TyParam {
pub name: ~str,
pub id: ast::NodeId,
references:- 13332: pub struct TyParam {
--
339: fn clean(&self) -> TyParam {
340: TyParam {
341: name: self.ident.clean(),
--
384: pub lifetimes: Vec<Lifetime>,
385: pub type_params: Vec<TyParam>,
386: }
librustdoc/clean.rs:1159:41-1159:41 -struct- definition:
pub struct ImportSource {
pub path: Path,
pub did: Option<ast::DefId>,
references:- 151160: pub struct ImportSource {
--
1345: fn resolve_use_source(path: Path, id: ast::NodeId) -> ImportSource {
1346: ImportSource {
1347: path: path,
librustdoc/html/format.rs:
543: impl fmt::Show for clean::ImportSource {
544: fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
librustdoc/clean.rs:
1160: pub struct ImportSource {
librustdoc/clean.rs:900:41-900:41 -struct- definition:
pub struct Span {
pub filename: ~str,
pub loline: uint,
references:- 13915: let hi = cm.lookup_char_pos(self.hi);
916: Span {
917: filename: filename.to_owned(),