From c670ae67b606ccdae475e0db2cddd2f3ece8c7e6 Mon Sep 17 00:00:00 2001 From: Alex Crawford Date: Fri, 16 Feb 2018 14:08:12 -0800 Subject: [PATCH] Remove unneeded string allocations --- src/libsyntax/codemap.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index ff6f32fc3be0b..df5845f6c217d 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -317,10 +317,10 @@ impl CodeMap { 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 @@ impl CodeMap { 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 {