From ede1f7d2a5a2f4038e3f3b2e953c44ee5ea06194 Mon Sep 17 00:00:00 2001 From: Matthias Krüger Date: Thu, 23 Aug 2018 10:14:52 +0200 Subject: use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into() --- src/libsyntax/parse/lexer/comments.rs | 2 +- src/libsyntax/parse/parser.rs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs index dde0466f43c..172a48ddba2 100644 --- a/src/libsyntax/parse/lexer/comments.rs +++ b/src/libsyntax/parse/lexer/comments.rs @@ -230,7 +230,7 @@ fn trim_whitespace_prefix_and_push_line(lines: &mut Vec, s: String, col: if col < len { (&s[col..len]).to_string() } else { - "".to_string() + String::new() } } None => s, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index e85b5dca2b7..74f6a65cc26 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -684,7 +684,7 @@ impl<'a> Parser<'a> { let mut i = tokens.iter(); // This might be a sign we need a connect method on Iterator. let b = i.next() - .map_or("".to_string(), |t| t.to_string()); + .map_or(String::new(), |t| t.to_string()); i.enumerate().fold(b, |mut b, (i, a)| { if tokens.len() > 2 && i == tokens.len() - 2 { b.push_str(", or "); @@ -786,7 +786,7 @@ impl<'a> Parser<'a> { } else { err.span_label(self.span, "expected identifier"); if self.token == token::Comma && self.look_ahead(1, |t| t.is_ident()) { - err.span_suggestion(self.span, "remove this comma", "".into()); + err.span_suggestion(self.span, "remove this comma", String::new()); } } err @@ -2506,7 +2506,7 @@ impl<'a> Parser<'a> { err.span_suggestion_short_with_applicability( self.span, "remove this comma", - "".to_owned(), + String::new(), Applicability::MachineApplicable ); err.note("the base struct must always be the last field"); @@ -3473,7 +3473,7 @@ impl<'a> Parser<'a> { e.span_suggestion_short_with_applicability( match_span, "try removing this `match`", - "".to_owned(), + String::new(), Applicability::MaybeIncorrect // speculative ); } @@ -3850,7 +3850,7 @@ impl<'a> Parser<'a> { if self.token == token::CloseDelim(token::Brace) { // If the struct looks otherwise well formed, recover and continue. if let Some(sp) = comma_sp { - err.span_suggestion_short(sp, "remove this comma", "".into()); + err.span_suggestion_short(sp, "remove this comma", String::new()); } err.emit(); break; @@ -3890,7 +3890,7 @@ impl<'a> Parser<'a> { err.multipart_suggestion( "move the `..` to the end of the field list", vec![ - (etc_span, "".into()), + (etc_span, String::new()), (self.span, format!("{}.. }}", if ate_comma { "" } else { ", " })), ], ); @@ -6190,7 +6190,7 @@ impl<'a> Parser<'a> { if token_str == ";" { let msg = "consider removing this semicolon"; err.span_suggestion_short_with_applicability( - self.span, msg, "".to_string(), Applicability::MachineApplicable + self.span, msg, String::new(), Applicability::MachineApplicable ); if !items.is_empty() { // Issue #51603 let previous_item = &items[items.len()-1]; -- cgit 1.4.1-3-g733a5