about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorPiotr Jawniak <sawyer47@gmail.com>2014-06-26 08:15:14 +0200
committerPiotr Jawniak <sawyer47@gmail.com>2014-06-26 08:56:49 +0200
commitf8e06c49650afd7c9ef749baa72cb8da59880f96 (patch)
tree5d9325ebd7357f26b59ee719b7b8be2d39e43c1d /src/libsyntax
parent99519cc8e645dd50522c2f32cf55ef8c15583012 (diff)
downloadrust-f8e06c49650afd7c9ef749baa72cb8da59880f96.tar.gz
rust-f8e06c49650afd7c9ef749baa72cb8da59880f96.zip
Remove unnecessary to_string calls
This commit removes superfluous to_string calls from various places
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast_map.rs42
-rw-r--r--src/libsyntax/ast_util.rs6
-rw-r--r--src/libsyntax/crateid.rs2
-rw-r--r--src/libsyntax/ext/deriving/generic/mod.rs2
-rw-r--r--src/libsyntax/parse/lexer/comments.rs2
-rw-r--r--src/libsyntax/print/pp.rs2
-rw-r--r--src/libsyntax/print/pprust.rs2
7 files changed, 26 insertions, 32 deletions
diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs
index 828e9ab12c2..1a9a910f38c 100644
--- a/src/libsyntax/ast_map.rs
+++ b/src/libsyntax/ast_map.rs
@@ -680,61 +680,55 @@ fn node_id_to_str(map: &Map, id: NodeId) -> String {
                 ItemImpl(..) => "impl",
                 ItemMac(..) => "macro"
             };
-            (format!("{} {} (id={})", item_str, path_str, id)).to_string()
+            format!("{} {} (id={})", item_str, path_str, id)
         }
         Some(NodeForeignItem(item)) => {
             let path_str = map.path_to_str_with_ident(id, item.ident);
-            (format!("foreign item {} (id={})", path_str, id)).to_string()
+            format!("foreign item {} (id={})", path_str, id)
         }
         Some(NodeMethod(m)) => {
-            (format!("method {} in {} (id={})",
+            format!("method {} in {} (id={})",
                     token::get_ident(m.ident),
-                    map.path_to_str(id), id)).to_string()
+                    map.path_to_str(id), id)
         }
         Some(NodeTraitMethod(ref tm)) => {
             let m = ast_util::trait_method_to_ty_method(&**tm);
-            (format!("method {} in {} (id={})",
+            format!("method {} in {} (id={})",
                     token::get_ident(m.ident),
-                    map.path_to_str(id), id)).to_string()
+                    map.path_to_str(id), id)
         }
         Some(NodeVariant(ref variant)) => {
-            (format!("variant {} in {} (id={})",
+            format!("variant {} in {} (id={})",
                     token::get_ident(variant.node.name),
-                    map.path_to_str(id), id)).to_string()
+                    map.path_to_str(id), id)
         }
         Some(NodeExpr(ref expr)) => {
-            (format!("expr {} (id={})",
-                    pprust::expr_to_str(&**expr), id)).to_string()
+            format!("expr {} (id={})", pprust::expr_to_str(&**expr), id)
         }
         Some(NodeStmt(ref stmt)) => {
-            (format!("stmt {} (id={})",
-                    pprust::stmt_to_str(&**stmt), id)).to_string()
+            format!("stmt {} (id={})", pprust::stmt_to_str(&**stmt), id)
         }
         Some(NodeArg(ref pat)) => {
-            (format!("arg {} (id={})",
-                    pprust::pat_to_str(&**pat), id)).to_string()
+            format!("arg {} (id={})", pprust::pat_to_str(&**pat), id)
         }
         Some(NodeLocal(ref pat)) => {
-            (format!("local {} (id={})",
-                    pprust::pat_to_str(&**pat), id)).to_string()
+            format!("local {} (id={})", pprust::pat_to_str(&**pat), id)
         }
         Some(NodePat(ref pat)) => {
-            (format!("pat {} (id={})", pprust::pat_to_str(&**pat), id)).to_string()
+            format!("pat {} (id={})", pprust::pat_to_str(&**pat), id)
         }
         Some(NodeBlock(ref block)) => {
-            (format!("block {} (id={})",
-                    pprust::block_to_str(&**block), id)).to_string()
+            format!("block {} (id={})", pprust::block_to_str(&**block), id)
         }
         Some(NodeStructCtor(_)) => {
-            (format!("struct_ctor {} (id={})",
-                    map.path_to_str(id), id)).to_string()
+            format!("struct_ctor {} (id={})", map.path_to_str(id), id)
         }
         Some(NodeLifetime(ref l)) => {
-            (format!("lifetime {} (id={})",
-                    pprust::lifetime_to_str(&**l), id)).to_string()
+            format!("lifetime {} (id={})",
+                    pprust::lifetime_to_str(&**l), id)
         }
         None => {
-            (format!("unknown node (id={})", id)).to_string()
+            format!("unknown node (id={})", id)
         }
     }
 }
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index df8cb328270..2a6f7bdb87e 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -30,7 +30,7 @@ pub fn path_name_i(idents: &[Ident]) -> String {
     // FIXME: Bad copies (#2543 -- same for everything else that says "bad")
     idents.iter().map(|i| {
         token::get_ident(*i).get().to_string()
-    }).collect::<Vec<String>>().connect("::").to_string()
+    }).collect::<Vec<String>>().connect("::")
 }
 
 // totally scary function: ignores all but the last element, should have
@@ -123,7 +123,7 @@ pub fn int_ty_to_str(t: IntTy, val: Option<i64>) -> String {
         // cast to a u64 so we can correctly print INT64_MIN. All integral types
         // are parsed as u64, so we wouldn't want to print an extra negative
         // sign.
-        Some(n) => format!("{}{}", n as u64, s).to_string(),
+        Some(n) => format!("{}{}", n as u64, s),
         None => s.to_string()
     }
 }
@@ -150,7 +150,7 @@ pub fn uint_ty_to_str(t: UintTy, val: Option<u64>) -> String {
     };
 
     match val {
-        Some(n) => format!("{}{}", n, s).to_string(),
+        Some(n) => format!("{}{}", n, s),
         None => s.to_string()
     }
 }
diff --git a/src/libsyntax/crateid.rs b/src/libsyntax/crateid.rs
index a3112cbb8be..b9298cca4f8 100644
--- a/src/libsyntax/crateid.rs
+++ b/src/libsyntax/crateid.rs
@@ -112,7 +112,7 @@ impl CrateId {
     }
 
     pub fn short_name_with_version(&self) -> String {
-        (format!("{}-{}", self.name, self.version_or_default())).to_string()
+        format!("{}-{}", self.name, self.version_or_default())
     }
 
     pub fn matches(&self, other: &CrateId) -> bool {
diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs
index 05269dbb44d..2b97687dbf8 100644
--- a/src/libsyntax/ext/deriving/generic/mod.rs
+++ b/src/libsyntax/ext/deriving/generic/mod.rs
@@ -1015,7 +1015,7 @@ impl<'a> TraitDef<'a> {
         to_set.expn_info = Some(box(GC) codemap::ExpnInfo {
             call_site: to_set,
             callee: codemap::NameAndSpan {
-                name: format!("deriving({})", trait_name).to_string(),
+                name: format!("deriving({})", trait_name),
                 format: codemap::MacroAttribute,
                 span: Some(self.span)
             }
diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs
index a009955f91a..f00c1ab4455 100644
--- a/src/libsyntax/parse/lexer/comments.rs
+++ b/src/libsyntax/parse/lexer/comments.rs
@@ -135,7 +135,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> String {
         let lines = vertical_trim(lines);
         let lines = horizontal_trim(lines);
 
-        return lines.connect("\n").to_string();
+        return lines.connect("\n");
     }
 
     fail!("not a doc-comment: {}", comment);
diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs
index 854aa80ca34..24ab4b38e54 100644
--- a/src/libsyntax/print/pp.rs
+++ b/src/libsyntax/print/pp.rs
@@ -111,7 +111,7 @@ impl Token {
 
 pub fn tok_str(t: Token) -> String {
     match t {
-        String(s, len) => return format!("STR({},{})", s, len).to_string(),
+        String(s, len) => return format!("STR({},{})", s, len),
         Break(_) => return "BREAK".to_string(),
         Begin(_) => return "BEGIN".to_string(),
         End => return "END".to_string(),
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 97e99ca692d..87ed2076d61 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -243,7 +243,7 @@ pub fn arg_to_str(arg: &ast::Arg) -> String {
 
 pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> String {
     match vis {
-        ast::Public => format!("pub {}", s).to_string(),
+        ast::Public => format!("pub {}", s),
         ast::Inherited => s.to_string()
     }
 }