diff options
| author | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-06-13 15:48:40 +0900 |
|---|---|---|
| committer | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-06-13 15:48:40 +0900 |
| commit | 77d6176e69de8bcdc15a12402ce7245f06ca2329 (patch) | |
| tree | 0f5bc75e1ef4e5e214bdb5ff3a427eef331df792 /compiler/rustc_parse/src/lexer | |
| parent | c570ab5a0bc2d5a553d0eeaa9923a1c05c84e64e (diff) | |
| download | rust-77d6176e69de8bcdc15a12402ce7245f06ca2329.tar.gz rust-77d6176e69de8bcdc15a12402ce7245f06ca2329.zip | |
remove unnecessary `to_string` and `String::new`
Diffstat (limited to 'compiler/rustc_parse/src/lexer')
| -rw-r--r-- | compiler/rustc_parse/src/lexer/unescape_error_reporting.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/lexer/unicode_chars.rs | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs b/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs index bec4561928c..273827864f1 100644 --- a/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs +++ b/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs @@ -105,7 +105,7 @@ pub(crate) fn emit_unescape_error( handler.span_suggestion( span, "consider removing the non-printing characters", - ch.to_string(), + ch, Applicability::MaybeIncorrect, ); } @@ -141,7 +141,7 @@ pub(crate) fn emit_unescape_error( .span_suggestion( char_span, "escape the character", - c.escape_default().to_string(), + c.escape_default(), Applicability::MachineApplicable, ) .emit(); @@ -157,7 +157,7 @@ pub(crate) fn emit_unescape_error( .span_suggestion( span, "escape the character", - "\\r".to_string(), + "\\r", Applicability::MachineApplicable, ) .emit(); @@ -299,7 +299,7 @@ pub(crate) fn emit_unescape_error( .span_suggestion_verbose( span.shrink_to_hi(), "terminate the unicode escape", - "}".to_string(), + "}", Applicability::MaybeIncorrect, ) .emit(); diff --git a/compiler/rustc_parse/src/lexer/unicode_chars.rs b/compiler/rustc_parse/src/lexer/unicode_chars.rs index faa686c3e57..2c68cc5895c 100644 --- a/compiler/rustc_parse/src/lexer/unicode_chars.rs +++ b/compiler/rustc_parse/src/lexer/unicode_chars.rs @@ -369,7 +369,7 @@ pub(super) fn check_for_substitution<'a>( "Unicode character '{}' ({}) looks like '{}' ({}), but it is not", ch, u_name, ascii_char, ascii_name ); - err.span_suggestion(span, &msg, ascii_char.to_string(), Applicability::MaybeIncorrect); + err.span_suggestion(span, &msg, ascii_char, Applicability::MaybeIncorrect); } token.clone() } |
