]> git.lizzy.rs Git - rust.git/commitdiff
Remove unneeded string allocations
authorAlex Crawford <rust@accounts.acrawford.com>
Fri, 16 Feb 2018 22:08:12 +0000 (14:08 -0800)
committerAlex Crawford <rust@accounts.acrawford.com>
Fri, 16 Feb 2018 23:23:28 +0000 (15:23 -0800)
src/libsyntax/codemap.rs

index ff6f32fc3be0bb7808319ccc756159e1abcfee69..df5845f6c217d5bfc2b82ca3c2135c0c5f34a415 100644 (file)
@@ -317,10 +317,10 @@ pub fn new_imported_filemap(&self,
 
     pub fn mk_substr_filename(&self, sp: Span) -> String {
         let pos = self.lookup_char_pos(sp.lo());
-        (format!("<{}:{}:{}>",
+        format!("<{}:{}:{}>",
                  pos.file.name,
                  pos.line,
-                 pos.col.to_usize() + 1)).to_string()
+                 pos.col.to_usize() + 1)
     }
 
     // If there is a doctest_offset, apply it to the line
@@ -462,12 +462,12 @@ pub fn span_to_string(&self, sp: Span) -> String {
 
         let lo = self.lookup_char_pos_adj(sp.lo());
         let hi = self.lookup_char_pos_adj(sp.hi());
-        return (format!("{}:{}:{}: {}:{}",
+        format!("{}:{}:{}: {}:{}",
                         lo.filename,
                         lo.line,
                         lo.col.to_usize() + 1,
                         hi.line,
-                        hi.col.to_usize() + 1)).to_string()
+                        hi.col.to_usize() + 1)
     }
 
     pub fn span_to_filename(&self, sp: Span) -> FileName {