Skip to content

Commit 3e2ae86

Browse files
committed
rustc_parse: avoid creating unnecessary intermediate strings
1 parent 6b01b35 commit 3e2ae86

File tree

1 file changed

+2
-1
lines changed
  • compiler/rustc_parse/src/parser

1 file changed

+2
-1
lines changed

compiler/rustc_parse/src/parser/item.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use rustc_span::lev_distance::lev_distance;
2222
use rustc_span::source_map::{self, Span};
2323
use rustc_span::symbol::{kw, sym, Ident, Symbol};
2424
use rustc_span::DUMMY_SP;
25+
use std::fmt::Write;
2526
use std::mem;
2627
use thin_vec::ThinVec;
2728

@@ -1109,7 +1110,7 @@ impl<'a> Parser<'a> {
11091110
let fixed_name_sp = ident.span.to(idents.last().unwrap().span);
11101111
let mut fixed_name = ident.name.to_string();
11111112
for part in idents {
1112-
fixed_name.push_str(&format!("_{}", part.name));
1113+
write!(fixed_name, "_{}", part.name).unwrap();
11131114
}
11141115
ident = Ident::from_str_and_span(&fixed_name, fixed_name_sp);
11151116

0 commit comments

Comments
 (0)