]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/clean.rs
Replace all ~"" with "".to_owned()
[rust.git] / src / librustdoc / clean.rs
index e36df4b4ee4ecb588245d6411b3f8091865d8ddb..fcd6629096c9940f22fd5c2891cacc87176f0b33 100644 (file)
 use rustc::metadata::csearch;
 use rustc::metadata::decoder;
 
+use std::local_data;
+use std::strbuf::StrBuf;
 use std;
 
 use core;
 use doctree;
 use visit_ast;
-use std::local_data;
 
 pub trait Clean<T> {
     fn clean(&self) -> T;
 }
 
-impl<T: Clean<U>, U> Clean<~[U]> for ~[T] {
-    fn clean(&self) -> ~[U] {
-        self.iter().map(|x| x.clean()).collect()
-    }
-}
-
 impl<T: Clean<U>, U> Clean<Vec<U>> for Vec<T> {
     fn clean(&self) -> Vec<U> {
         self.iter().map(|x| x.clean()).collect()
@@ -70,9 +65,9 @@ fn clean(&self) -> Vec<U> {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Crate {
-    name: ~str,
-    module: Option<Item>,
-    externs: ~[(ast::CrateNum, ExternalCrate)],
+    pub name: ~str,
+    pub module: Option<Item>,
+    pub externs: Vec<(ast::CrateNum, ExternalCrate)>,
 }
 
 impl<'a> Clean<Crate> for visit_ast::RustdocVisitor<'a> {
@@ -80,13 +75,13 @@ fn clean(&self) -> Crate {
         use syntax::attr::find_crateid;
         let cx = local_data::get(super::ctxtkey, |x| *x.unwrap());
 
-        let mut externs = ~[];
+        let mut externs = Vec::new();
         cx.sess().cstore.iter_crate_data(|n, meta| {
             externs.push((n, meta.clean()));
         });
 
         Crate {
-            name: match find_crateid(self.attrs) {
+            name: match find_crateid(self.attrs.as_slice()) {
                 Some(n) => n.name,
                 None => fail!("rustdoc requires a `crate_id` crate attribute"),
             },
@@ -98,8 +93,8 @@ fn clean(&self) -> Crate {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct ExternalCrate {
-    name: ~str,
-    attrs: ~[Attribute],
+    pub name: ~str,
+    pub attrs: Vec<Attribute>,
 }
 
 impl Clean<ExternalCrate> for cstore::crate_metadata {
@@ -119,13 +114,13 @@ fn clean(&self) -> ExternalCrate {
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Item {
     /// Stringified span
-    source: Span,
+    pub source: Span,
     /// Not everything has a name. E.g., impls
-    name: Option<~str>,
-    attrs: ~[Attribute],
-    inner: ItemEnum,
-    visibility: Option<Visibility>,
-    id: ast::NodeId,
+    pub name: Option<~str>,
+    pub attrs: Vec<Attribute> ,
+    pub inner: ItemEnum,
+    pub visibility: Option<Visibility>,
+    pub id: ast::NodeId,
 }
 
 impl Item {
@@ -180,20 +175,26 @@ pub enum ItemEnum {
     StaticItem(Static),
     TraitItem(Trait),
     ImplItem(Impl),
+    /// `use` and `extern crate`
     ViewItemItem(ViewItem),
+    /// A method signature only. Used for required methods in traits (ie,
+    /// non-default-methods).
     TyMethodItem(TyMethod),
+    /// A method with a body.
     MethodItem(Method),
     StructFieldItem(StructField),
     VariantItem(Variant),
+    /// `fn`s from an extern block
     ForeignFunctionItem(Function),
+    /// `static`s from an extern block
     ForeignStaticItem(Static),
     MacroItem(Macro),
 }
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Module {
-    items: ~[Item],
-    is_crate: bool,
+    pub items: Vec<Item>,
+    pub is_crate: bool,
 }
 
 impl Clean<Item> for doctree::Module {
@@ -201,15 +202,15 @@ fn clean(&self) -> Item {
         let name = if self.name.is_some() {
             self.name.unwrap().clean()
         } else {
-            ~""
+            "".to_owned()
         };
-        let mut foreigns = ~[];
+        let mut foreigns = Vec::new();
         for subforeigns in self.foreigns.clean().move_iter() {
             for foreign in subforeigns.move_iter() {
                 foreigns.push(foreign)
             }
         }
-        let items: ~[~[Item]] = ~[
+        let items: Vec<Vec<Item> > = vec!(
             self.structs.clean().move_iter().collect(),
             self.enums.clean().move_iter().collect(),
             self.fns.clean().move_iter().collect(),
@@ -221,7 +222,7 @@ fn clean(&self) -> Item {
             self.impls.clean().move_iter().collect(),
             self.view_items.clean().move_iter().collect(),
             self.macros.clean().move_iter().collect()
-        ];
+        );
         Item {
             name: Some(name),
             attrs: self.attrs.clean(),
@@ -230,7 +231,9 @@ fn clean(&self) -> Item {
             id: self.id,
             inner: ModuleItem(Module {
                is_crate: self.is_crate,
-               items: items.concat_vec(),
+               items: items.iter()
+                           .flat_map(|x| x.iter().map(|x| (*x).clone()))
+                           .collect(),
             })
         }
     }
@@ -239,7 +242,7 @@ fn clean(&self) -> Item {
 #[deriving(Clone, Encodable, Decodable)]
 pub enum Attribute {
     Word(~str),
-    List(~str, ~[Attribute]),
+    List(~str, Vec<Attribute> ),
     NameValue(~str, ~str)
 }
 
@@ -287,9 +290,9 @@ fn name_str_pair(&self) -> Option<(InternedString, InternedString)> {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct TyParam {
-    name: ~str,
-    id: ast::NodeId,
-    bounds: ~[TyParamBound]
+    pub name: ~str,
+    pub id: ast::NodeId,
+    pub bounds: Vec<TyParamBound>,
 }
 
 impl Clean<TyParam> for ast::TyParam {
@@ -337,8 +340,8 @@ fn clean(&self) -> Lifetime {
 // maybe use a Generic enum and use ~[Generic]?
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Generics {
-    lifetimes: ~[Lifetime],
-    type_params: ~[TyParam]
+    pub lifetimes: Vec<Lifetime>,
+    pub type_params: Vec<TyParam>,
 }
 
 impl Clean<Generics> for ast::Generics {
@@ -352,10 +355,10 @@ fn clean(&self) -> Generics {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Method {
-    generics: Generics,
-    self_: SelfTy,
-    purity: ast::Purity,
-    decl: FnDecl,
+    pub generics: Generics,
+    pub self_: SelfTy,
+    pub fn_style: ast::FnStyle,
+    pub decl: FnDecl,
 }
 
 impl Clean<Item> for ast::Method {
@@ -370,7 +373,7 @@ fn clean(&self) -> Item {
             },
             output: (self.decl.output.clean()),
             cf: self.decl.cf.clean(),
-            attrs: ~[]
+            attrs: Vec::new()
         };
         Item {
             name: Some(self.ident.clean()),
@@ -381,7 +384,7 @@ fn clean(&self) -> Item {
             inner: MethodItem(Method {
                 generics: self.generics.clean(),
                 self_: self.explicit_self.clean(),
-                purity: self.purity.clone(),
+                fn_style: self.fn_style.clone(),
                 decl: decl,
             }),
         }
@@ -390,10 +393,10 @@ fn clean(&self) -> Item {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct TyMethod {
-    purity: ast::Purity,
-    decl: FnDecl,
-    generics: Generics,
-    self_: SelfTy,
+    pub fn_style: ast::FnStyle,
+    pub decl: FnDecl,
+    pub generics: Generics,
+    pub self_: SelfTy,
 }
 
 impl Clean<Item> for ast::TypeMethod {
@@ -408,7 +411,7 @@ fn clean(&self) -> Item {
             },
             output: (self.decl.output.clean()),
             cf: self.decl.cf.clean(),
-            attrs: ~[]
+            attrs: Vec::new()
         };
         Item {
             name: Some(self.ident.clean()),
@@ -417,7 +420,7 @@ fn clean(&self) -> Item {
             id: self.id,
             visibility: None,
             inner: TyMethodItem(TyMethod {
-                purity: self.purity.clone(),
+                fn_style: self.fn_style.clone(),
                 decl: decl,
                 self_: self.explicit_self.clean(),
                 generics: self.generics.clean(),
@@ -447,9 +450,9 @@ fn clean(&self) -> SelfTy {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Function {
-    decl: FnDecl,
-    generics: Generics,
-    purity: ast::Purity,
+    pub decl: FnDecl,
+    pub generics: Generics,
+    pub fn_style: ast::FnStyle,
 }
 
 impl Clean<Item> for doctree::Function {
@@ -463,7 +466,7 @@ fn clean(&self) -> Item {
             inner: FunctionItem(Function {
                 decl: self.decl.clean(),
                 generics: self.generics.clean(),
-                purity: self.purity,
+                fn_style: self.fn_style,
             }),
         }
     }
@@ -471,27 +474,23 @@ fn clean(&self) -> Item {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct ClosureDecl {
-    sigil: ast::Sigil,
-    region: Option<Lifetime>,
-    lifetimes: ~[Lifetime],
-    decl: FnDecl,
-    onceness: ast::Onceness,
-    purity: ast::Purity,
-    bounds: ~[TyParamBound]
+    pub lifetimes: Vec<Lifetime>,
+    pub decl: FnDecl,
+    pub onceness: ast::Onceness,
+    pub fn_style: ast::FnStyle,
+    pub bounds: Vec<TyParamBound>,
 }
 
 impl Clean<ClosureDecl> for ast::ClosureTy {
     fn clean(&self) -> ClosureDecl {
         ClosureDecl {
-            sigil: self.sigil,
-            region: self.region.clean(),
             lifetimes: self.lifetimes.clean().move_iter().collect(),
             decl: self.decl.clean(),
             onceness: self.onceness,
-            purity: self.purity,
+            fn_style: self.fn_style,
             bounds: match self.bounds {
                 Some(ref x) => x.clean().move_iter().collect(),
-                None        => ~[]
+                None        => Vec::new()
             },
         }
     }
@@ -499,15 +498,15 @@ fn clean(&self) -> ClosureDecl {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct FnDecl {
-    inputs: Arguments,
-    output: Type,
-    cf: RetStyle,
-    attrs: ~[Attribute]
+    pub inputs: Arguments,
+    pub output: Type,
+    pub cf: RetStyle,
+    pub attrs: Vec<Attribute>,
 }
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Arguments {
-    values: ~[Argument],
+    pub values: Vec<Argument>,
 }
 
 impl Clean<FnDecl> for ast::FnDecl {
@@ -518,16 +517,16 @@ fn clean(&self) -> FnDecl {
             },
             output: (self.output.clean()),
             cf: self.cf.clean(),
-            attrs: ~[]
+            attrs: Vec::new()
         }
     }
 }
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Argument {
-    type_: Type,
-    name: ~str,
-    id: ast::NodeId
+    pub type_: Type,
+    pub name: ~str,
+    pub id: ast::NodeId,
 }
 
 impl Clean<Argument> for ast::Arg {
@@ -557,9 +556,9 @@ fn clean(&self) -> RetStyle {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Trait {
-    methods: ~[TraitMethod],
-    generics: Generics,
-    parents: ~[Type],
+    pub methods: Vec<TraitMethod>,
+    pub generics: Generics,
+    pub parents: Vec<Type>,
 }
 
 impl Clean<Item> for doctree::Trait {
@@ -628,17 +627,17 @@ fn clean(&self) -> TraitMethod {
 pub enum Type {
     /// structs/enums/traits (anything that'd be an ast::TyPath)
     ResolvedPath {
-        path: Path,
-        typarams: Option<~[TyParamBound]>,
-        id: ast::NodeId,
+        pub path: Path,
+        pub typarams: Option<Vec<TyParamBound>>,
+        pub id: ast::NodeId,
     },
     /// Same as above, but only external variants
     ExternalPath {
-        path: Path,
-        typarams: Option<~[TyParamBound]>,
-        fqn: ~[~str],
-        kind: TypeKind,
-        krate: ast::CrateNum,
+        pub path: Path,
+        pub typarams: Option<Vec<TyParamBound>>,
+        pub fqn: Vec<~str>,
+        pub kind: TypeKind,
+        pub krate: ast::CrateNum,
     },
     // I have no idea how to usefully use this.
     TyParamBinder(ast::NodeId),
@@ -649,10 +648,11 @@ pub enum Type {
     Self(ast::NodeId),
     /// Primitives are just the fixed-size numeric types (plus int/uint/float), and char.
     Primitive(ast::PrimTy),
-    Closure(~ClosureDecl),
+    Closure(~ClosureDecl, Option<Lifetime>),
+    Proc(~ClosureDecl),
     /// extern "ABI" fn
     BareFunction(~BareFunctionDecl),
-    Tuple(~[Type]),
+    Tuple(Vec<Type> ),
     Vector(~Type),
     FixedVector(~Type, ~str),
     String,
@@ -664,7 +664,11 @@ pub enum Type {
     Unique(~Type),
     Managed(~Type),
     RawPointer(Mutability, ~Type),
-    BorrowedRef { lifetime: Option<Lifetime>, mutability: Mutability, type_: ~Type},
+    BorrowedRef {
+        pub lifetime: Option<Lifetime>,
+        pub mutability: Mutability,
+        pub type_: ~Type,
+    },
     // region, raw, other boxes, mutable
 }
 
@@ -699,7 +703,8 @@ fn clean(&self) -> Type {
                              tpbs.clean().map(|x| x.move_iter().collect()),
                              id)
             }
-            TyClosure(ref c) => Closure(~c.clean()),
+            TyClosure(ref c, region) => Closure(~c.clean(), region.clean()),
+            TyProc(ref c) => Proc(~c.clean()),
             TyBareFn(ref barefn) => BareFunction(~barefn.clean()),
             TyBot => Bottom,
             ref x => fail!("Unimplemented type {:?}", x),
@@ -709,7 +714,7 @@ fn clean(&self) -> Type {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct StructField {
-    type_: Type,
+    pub type_: Type,
 }
 
 impl Clean<Item> for ast::StructField {
@@ -741,10 +746,10 @@ fn clean(&self) -> Option<Visibility> {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Struct {
-    struct_type: doctree::StructType,
-    generics: Generics,
-    fields: ~[Item],
-    fields_stripped: bool,
+    pub struct_type: doctree::StructType,
+    pub generics: Generics,
+    pub fields: Vec<Item>,
+    pub fields_stripped: bool,
 }
 
 impl Clean<Item> for doctree::Struct {
@@ -770,9 +775,9 @@ fn clean(&self) -> Item {
 /// only as a variant in an enum.
 #[deriving(Clone, Encodable, Decodable)]
 pub struct VariantStruct {
-    struct_type: doctree::StructType,
-    fields: ~[Item],
-    fields_stripped: bool,
+    pub struct_type: doctree::StructType,
+    pub fields: Vec<Item>,
+    pub fields_stripped: bool,
 }
 
 impl Clean<VariantStruct> for syntax::ast::StructDef {
@@ -787,9 +792,9 @@ fn clean(&self) -> VariantStruct {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Enum {
-    variants: ~[Item],
-    generics: Generics,
-    variants_stripped: bool,
+    pub variants: Vec<Item>,
+    pub generics: Generics,
+    pub variants_stripped: bool,
 }
 
 impl Clean<Item> for doctree::Enum {
@@ -811,7 +816,7 @@ fn clean(&self) -> Item {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Variant {
-    kind: VariantKind,
+    pub kind: VariantKind,
 }
 
 impl Clean<Item> for doctree::Variant {
@@ -832,7 +837,7 @@ fn clean(&self) -> Item {
 #[deriving(Clone, Encodable, Decodable)]
 pub enum VariantKind {
     CLikeVariant,
-    TupleVariant(~[Type]),
+    TupleVariant(Vec<Type> ),
     StructVariant(VariantStruct),
 }
 
@@ -853,11 +858,11 @@ fn clean(&self) -> VariantKind {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Span {
-    filename: ~str,
-    loline: uint,
-    locol: uint,
-    hiline: uint,
-    hicol: uint,
+    pub filename: ~str,
+    pub loline: uint,
+    pub locol: uint,
+    pub hiline: uint,
+    pub hicol: uint,
 }
 
 impl Clean<Span> for syntax::codemap::Span {
@@ -878,8 +883,8 @@ fn clean(&self) -> Span {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Path {
-    global: bool,
-    segments: ~[PathSegment],
+    pub global: bool,
+    pub segments: Vec<PathSegment>,
 }
 
 impl Clean<Path> for ast::Path {
@@ -893,9 +898,9 @@ fn clean(&self) -> Path {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct PathSegment {
-    name: ~str,
-    lifetimes: ~[Lifetime],
-    types: ~[Type],
+    pub name: ~str,
+    pub lifetimes: Vec<Lifetime>,
+    pub types: Vec<Type>,
 }
 
 impl Clean<PathSegment> for ast::PathSegment {
@@ -911,7 +916,7 @@ fn clean(&self) -> PathSegment {
 fn path_to_str(p: &ast::Path) -> ~str {
     use syntax::parse::token;
 
-    let mut s = ~"";
+    let mut s = StrBuf::new();
     let mut first = true;
     for i in p.segments.iter().map(|x| token::get_ident(x.identifier)) {
         if !first || p.global {
@@ -921,7 +926,7 @@ fn path_to_str(p: &ast::Path) -> ~str {
         }
         s.push_str(i.get());
     }
-    s
+    s.into_owned()
 }
 
 impl Clean<~str> for ast::Ident {
@@ -932,8 +937,8 @@ fn clean(&self) -> ~str {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Typedef {
-    type_: Type,
-    generics: Generics,
+    pub type_: Type,
+    pub generics: Generics,
 }
 
 impl Clean<Item> for doctree::Typedef {
@@ -954,34 +959,34 @@ fn clean(&self) -> Item {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct BareFunctionDecl {
-    purity: ast::Purity,
-    generics: Generics,
-    decl: FnDecl,
-    abi: ~str
+    pub fn_style: ast::FnStyle,
+    pub generics: Generics,
+    pub decl: FnDecl,
+    pub abi: ~str,
 }
 
 impl Clean<BareFunctionDecl> for ast::BareFnTy {
     fn clean(&self) -> BareFunctionDecl {
         BareFunctionDecl {
-            purity: self.purity,
+            fn_style: self.fn_style,
             generics: Generics {
                 lifetimes: self.lifetimes.clean().move_iter().collect(),
-                type_params: ~[],
+                type_params: Vec::new(),
             },
             decl: self.decl.clean(),
-            abi: self.abis.to_str(),
+            abi: self.abi.to_str(),
         }
     }
 }
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Static {
-    type_: Type,
-    mutability: Mutability,
+    pub type_: Type,
+    pub mutability: Mutability,
     /// It's useful to have the value of a static documented, but I have no
     /// desire to represent expressions (that'd basically be all of the AST,
     /// which is huge!). So, have a string.
-    expr: ~str,
+    pub expr: ~str,
 }
 
 impl Clean<Item> for doctree::Static {
@@ -1019,14 +1024,26 @@ fn clean(&self) -> Mutability {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Impl {
-    generics: Generics,
-    trait_: Option<Type>,
-    for_: Type,
-    methods: ~[Item],
+    pub generics: Generics,
+    pub trait_: Option<Type>,
+    pub for_: Type,
+    pub methods: Vec<Item>,
+    pub derived: bool,
 }
 
 impl Clean<Item> for doctree::Impl {
     fn clean(&self) -> Item {
+        let mut derived = false;
+        for attr in self.attrs.iter() {
+            match attr.node.value.node {
+                ast::MetaWord(ref s) => {
+                    if s.get() == "automatically_derived" {
+                        derived = true;
+                    }
+                }
+                _ => {}
+            }
+        }
         Item {
             name: None,
             attrs: self.attrs.clean(),
@@ -1038,6 +1055,7 @@ fn clean(&self) -> Item {
                 trait_: self.trait_.clean(),
                 for_: self.for_.clean(),
                 methods: self.methods.clean(),
+                derived: derived,
             }),
         }
     }
@@ -1045,7 +1063,7 @@ fn clean(&self) -> Item {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct ViewItem {
-    inner: ViewItemInner
+    pub inner: ViewItemInner,
 }
 
 impl Clean<Item> for ast::ViewItem {
@@ -1066,7 +1084,7 @@ fn clean(&self) -> Item {
 #[deriving(Clone, Encodable, Decodable)]
 pub enum ViewItemInner {
     ExternCrate(~str, Option<~str>, ast::NodeId),
-    Import(~[ViewPath])
+    Import(Vec<ViewPath>)
 }
 
 impl Clean<ViewItemInner> for ast::ViewItem_ {
@@ -1093,13 +1111,13 @@ pub enum ViewPath {
     // use source::*;
     GlobImport(ImportSource),
     // use source::{a, b, c};
-    ImportList(ImportSource, ~[ViewListIdent]),
+    ImportList(ImportSource, Vec<ViewListIdent> ),
 }
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct ImportSource {
-    path: Path,
-    did: Option<ast::DefId>,
+    pub path: Path,
+    pub did: Option<ast::DefId>,
 }
 
 impl Clean<ViewPath> for ast::ViewPath {
@@ -1119,8 +1137,8 @@ fn clean(&self) -> ViewPath {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct ViewListIdent {
-    name: ~str,
-    source: Option<ast::DefId>,
+    pub name: ~str,
+    pub source: Option<ast::DefId>,
 }
 
 impl Clean<ViewListIdent> for ast::PathListIdent {
@@ -1145,14 +1163,14 @@ fn clean(&self) -> Item {
                 ForeignFunctionItem(Function {
                     decl: decl.clean(),
                     generics: generics.clean(),
-                    purity: ast::ExternFn,
+                    fn_style: ast::ExternFn,
                 })
             }
             ast::ForeignItemStatic(ref ty, mutbl) => {
                 ForeignStaticItem(Static {
                     type_: ty.clean(),
                     mutability: if mutbl {Mutable} else {Immutable},
-                    expr: ~"",
+                    expr: "".to_owned(),
                 })
             }
         };
@@ -1179,7 +1197,7 @@ fn to_src(&self) -> ~str {
         let cm = local_data::get(super::ctxtkey, |x| x.unwrap().clone()).sess().codemap().clone();
         let sn = match cm.span_to_snippet(*self) {
             Some(x) => x,
-            None    => ~""
+            None    => "".to_owned()
         };
         debug!("got snippet {}", sn);
         sn
@@ -1189,15 +1207,15 @@ fn to_src(&self) -> ~str {
 fn lit_to_str(lit: &ast::Lit) -> ~str {
     match lit.node {
         ast::LitStr(ref st, _) => st.get().to_owned(),
-        ast::LitBinary(ref data) => format!("{:?}", data.deref().as_slice()),
-        ast::LitChar(c) => ~"'" + std::char::from_u32(c).unwrap().to_str() + "'",
+        ast::LitBinary(ref data) => format!("{:?}", data.as_slice()),
+        ast::LitChar(c) => "'".to_owned() + std::char::from_u32(c).unwrap().to_str() + "'",
         ast::LitInt(i, _t) => i.to_str(),
         ast::LitUint(u, _t) => u.to_str(),
         ast::LitIntUnsuffixed(i) => i.to_str(),
         ast::LitFloat(ref f, _t) => f.get().to_str(),
         ast::LitFloatUnsuffixed(ref f) => f.get().to_str(),
         ast::LitBool(b) => b.to_str(),
-        ast::LitNil => ~"",
+        ast::LitNil => "".to_owned(),
     }
 }
 
@@ -1206,19 +1224,19 @@ fn name_from_pat(p: &ast::Pat) -> ~str {
     debug!("Trying to get a name from pattern: {:?}", p);
 
     match p.node {
-        PatWild => ~"_",
-        PatWildMulti => ~"..",
+        PatWild => "_".to_owned(),
+        PatWildMulti => "..".to_owned(),
         PatIdent(_, ref p, _) => path_to_str(p),
         PatEnum(ref p, _) => path_to_str(p),
         PatStruct(..) => fail!("tried to get argument name from pat_struct, \
                                 which is not allowed in function arguments"),
-        PatTup(..) => ~"(tuple arg NYI)",
+        PatTup(..) => "(tuple arg NYI)".to_owned(),
         PatUniq(p) => name_from_pat(p),
         PatRegion(p) => name_from_pat(p),
         PatLit(..) => {
             warn!("tried to get argument name from PatLit, \
                   which is silly in function arguments");
-            ~"()"
+            "()".to_owned()
         },
         PatRange(..) => fail!("tried to get argument name from PatRange, \
                               which is not allowed in function arguments"),
@@ -1228,7 +1246,7 @@ fn name_from_pat(p: &ast::Pat) -> ~str {
 }
 
 /// Given a Type, resolve it using the def_map
-fn resolve_type(path: Path, tpbs: Option<~[TyParamBound]>,
+fn resolve_type(path: Path, tpbs: Option<Vec<TyParamBound> >,
                 id: ast::NodeId) -> Type {
     let cx = local_data::get(super::ctxtkey, |x| *x.unwrap());
     let tycx = match cx.maybe_typed {
@@ -1237,16 +1255,15 @@ fn resolve_type(path: Path, tpbs: Option<~[TyParamBound]>,
         core::NotTyped(_) => return Bool
     };
     debug!("searching for {:?} in defmap", id);
-    let def_map = tycx.def_map.borrow();
-    let d = match def_map.get().find(&id) {
-        Some(k) => k,
+    let d = match tycx.def_map.borrow().find(&id) {
+        Some(&k) => k,
         None => {
             debug!("could not find {:?} in defmap (`{}`)", id, tycx.map.node_to_str(id));
             fail!("Unexpected failure: unresolved id not in defmap (this is a bug!)")
         }
     };
 
-    let (def_id, kind) = match *d {
+    let (def_id, kind) = match d {
         ast::DefFn(i, _) => (i, TypeFunction),
         ast::DefSelfTy(i) => return Self(i),
         ast::DefTy(i) => (i, TypeEnum),
@@ -1271,9 +1288,14 @@ fn resolve_type(path: Path, tpbs: Option<~[TyParamBound]>,
         ResolvedPath{ path: path, typarams: tpbs, id: def_id.node }
     } else {
         let fqn = csearch::get_item_path(tycx, def_id);
-        let fqn = fqn.move_iter().map(|i| i.to_str()).to_owned_vec();
-        ExternalPath{ path: path, typarams: tpbs, fqn: fqn, kind: kind,
-                      krate: def_id.krate }
+        let fqn = fqn.move_iter().map(|i| i.to_str()).collect();
+        ExternalPath {
+            path: path,
+            typarams: tpbs,
+            fqn: fqn,
+            kind: kind,
+            krate: def_id.krate,
+        }
     }
 }
 
@@ -1288,8 +1310,7 @@ fn resolve_def(id: ast::NodeId) -> Option<ast::DefId> {
     let cx = local_data::get(super::ctxtkey, |x| *x.unwrap());
     match cx.maybe_typed {
         core::Typed(ref tcx) => {
-            let def_map = tcx.def_map.borrow();
-            def_map.get().find(&id).map(|&d| ast_util::def_id_of_def(d))
+            tcx.def_map.borrow().find(&id).map(|&d| ast_util::def_id_of_def(d))
         }
         core::NotTyped(_) => None
     }
@@ -1297,7 +1318,7 @@ fn resolve_def(id: ast::NodeId) -> Option<ast::DefId> {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct Macro {
-    source: ~str,
+    pub source: ~str,
 }
 
 impl Clean<Item> for doctree::Macro {