Skip to content

Commit

Permalink
use str-literal instead of char-literal before converting to String s…
Browse files Browse the repository at this point in the history
…ince str to String conversion is cheaper.

See rust-lang#73462
  • Loading branch information
matthiaskrgr committed Jun 18, 2020
1 parent 2935d29 commit aadba4e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/librustc_parse/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down

0 comments on commit aadba4e

Please sign in to comment.