diff options
| author | kennytm <kennytm@gmail.com> | 2018-08-24 16:44:35 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-24 16:44:35 +0800 |
| commit | d13c61208a978cb0dc8b81a64cf56364fa676ddb (patch) | |
| tree | 8763d791111064026baddf4092e9fe5f9cc30f33 /src/libsyntax/parse | |
| parent | 714e5b3c4663c353b8bb69a7276664d7b1b04c29 (diff) | |
| parent | ede1f7d2a5a2f4038e3f3b2e953c44ee5ea06194 (diff) | |
| download | rust-d13c61208a978cb0dc8b81a64cf56364fa676ddb.tar.gz rust-d13c61208a978cb0dc8b81a64cf56364fa676ddb.zip | |
Rollup merge of #53563 - matthiaskrgr:String, r=varkor
use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into()
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/lexer/comments.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 14 |
2 files changed, 8 insertions, 8 deletions
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<String>, 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 1e72f834b8e..725360b842d 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 @@ -2518,7 +2518,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"); @@ -3485,7 +3485,7 @@ impl<'a> Parser<'a> { e.span_suggestion_short_with_applicability( match_span, "try removing this `match`", - "".to_owned(), + String::new(), Applicability::MaybeIncorrect // speculative ); } @@ -3862,7 +3862,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; @@ -3902,7 +3902,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 { ", " })), ], ); @@ -6210,7 +6210,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]; |
