]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/clean.rs
Replace all ~"" with "".to_owned()
[rust.git] / src / librustdoc / clean.rs
index 7430c7ccb49800f84d6da43f9644efc84285b623..fcd6629096c9940f22fd5c2891cacc87176f0b33 100644 (file)
@@ -202,7 +202,7 @@ fn clean(&self) -> Item {
         let name = if self.name.is_some() {
             self.name.unwrap().clean()
         } else {
-            ~""
+            "".to_owned()
         };
         let mut foreigns = Vec::new();
         for subforeigns in self.foreigns.clean().move_iter() {
@@ -474,8 +474,6 @@ fn clean(&self) -> Item {
 
 #[deriving(Clone, Encodable, Decodable)]
 pub struct ClosureDecl {
-    pub sigil: ast::Sigil,
-    pub region: Option<Lifetime>,
     pub lifetimes: Vec<Lifetime>,
     pub decl: FnDecl,
     pub onceness: ast::Onceness,
@@ -486,8 +484,6 @@ pub struct ClosureDecl {
 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,
@@ -652,7 +648,8 @@ 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(Vec<Type> ),
@@ -706,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),
@@ -1172,7 +1170,7 @@ fn clean(&self) -> Item {
                 ForeignStaticItem(Static {
                     type_: ty.clean(),
                     mutability: if mutbl {Mutable} else {Immutable},
-                    expr: ~"",
+                    expr: "".to_owned(),
                 })
             }
         };
@@ -1199,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
@@ -1210,14 +1208,14 @@ 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.as_slice()),
-        ast::LitChar(c) => ~"'" + std::char::from_u32(c).unwrap().to_str() + "'",
+        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(),
     }
 }
 
@@ -1226,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"),