From aadba4ee67d415711fcdae9198cd87fbb8f758ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Thu, 18 Jun 2020 03:38:29 +0200 Subject: [PATCH] use str-literal instead of char-literal before converting to String since str to String conversion is cheaper. See https://github.com/rust-lang/rust/issues/73462 --- src/librustc_parse/parser/item.rs | 4 ++-- src/librustc_typeck/check/method/suggest.rs | 4 ++-- src/librustc_typeck/collect.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustc_parse/parser/item.rs b/src/librustc_parse/parser/item.rs index 6f13d7994d17d..a096627a3f19e 100644 --- a/src/librustc_parse/parser/item.rs +++ b/src/librustc_parse/parser/item.rs @@ -1403,7 +1403,7 @@ impl<'a> Parser<'a> { }; err.multipart_suggestion( "change the delimiters to curly braces", - vec![(open, "{".to_string()), (close, '}'.to_string())], + vec![(open, "{".to_string()), (close, "}".to_string())], Applicability::MaybeIncorrect, ); } else { @@ -1417,7 +1417,7 @@ impl<'a> Parser<'a> { err.span_suggestion( span.shrink_to_hi(), "add a semicolon", - ';'.to_string(), + ";".to_string(), Applicability::MaybeIncorrect, ); err.emit(); diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 67bdd04d3715c..09e41d6914d6d 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -468,8 +468,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { item_name, ), vec![ - (expr_span.shrink_to_lo(), '('.to_string()), - (expr_span.shrink_to_hi(), ')'.to_string()), + (expr_span.shrink_to_lo(), "(".to_string()), + (expr_span.shrink_to_hi(), ")".to_string()), ], Applicability::MachineApplicable, ); diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 1d59d749634ee..920aadb101068 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -464,7 +464,7 @@ fn get_new_lifetime_name<'tcx>( let a_to_z_repeat_n = |n| { (b'a'..=b'z').map(move |c| { - let mut s = '\''.to_string(); + let mut s = "'".to_string(); s.extend(std::iter::repeat(char::from(c)).take(n)); s })