diff options
| author | 5225225 <5225225@mailbox.org> | 2021-11-13 15:08:20 +0000 |
|---|---|---|
| committer | 5225225 <5225225@mailbox.org> | 2021-11-16 08:06:31 +0000 |
| commit | 09e59c2875e351cacd2f9cb653fee383acf02121 (patch) | |
| tree | b680fb6981f782364029d6bc503c1ea5edabe968 /compiler/rustc_parse/src | |
| parent | 17b5e2d167e8dec14117f0722c72444d2e3a5b2e (diff) | |
| download | rust-09e59c2875e351cacd2f9cb653fee383acf02121.tar.gz rust-09e59c2875e351cacd2f9cb653fee383acf02121.zip | |
Inline printable function
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/lexer/unescape_error_reporting.rs | 12 |
1 files changed, 7 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 aa7ab4a953c..7f68112a427 100644 --- a/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs +++ b/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs @@ -7,10 +7,6 @@ use rustc_errors::{pluralize, Applicability, Handler}; use rustc_lexer::unescape::{EscapeError, Mode}; use rustc_span::{BytePos, Span}; -fn printing(ch: char) -> bool { - unicode_width::UnicodeWidthChar::width(ch).unwrap_or(0) != 0 && !ch.is_whitespace() -} - pub(crate) fn emit_unescape_error( handler: &Handler, // interior part of the literal, without quotes @@ -87,7 +83,13 @@ pub(crate) fn emit_unescape_error( ); } } else { - let printable: Vec<char> = lit.chars().filter(|x| printing(*x)).collect(); + let printable: Vec<char> = lit + .chars() + .filter(|&x| { + unicode_width::UnicodeWidthChar::width(x).unwrap_or(0) != 0 + && !x.is_whitespace() + }) + .collect(); if let [ch] = printable.as_slice() { has_help = true; |
