Skip to content

Commit e197392

Browse files
committed
Inline printable function
1 parent 6a34355 commit e197392

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

compiler/rustc_parse/src/lexer/unescape_error_reporting.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ use rustc_errors::{pluralize, Applicability, Handler};
77
use rustc_lexer::unescape::{EscapeError, Mode};
88
use rustc_span::{BytePos, Span};
99

10-
fn printing(ch: char) -> bool {
11-
unicode_width::UnicodeWidthChar::width(ch).unwrap_or(0) != 0 && !ch.is_whitespace()
12-
}
13-
1410
pub(crate) fn emit_unescape_error(
1511
handler: &Handler,
1612
// interior part of the literal, without quotes
@@ -87,7 +83,13 @@ pub(crate) fn emit_unescape_error(
8783
);
8884
}
8985
} else {
90-
let printable: Vec<char> = lit.chars().filter(|x| printing(*x)).collect();
86+
let printable: Vec<char> = lit
87+
.chars()
88+
.filter(|&x| {
89+
unicode_width::UnicodeWidthChar::width(x).unwrap_or(0) != 0
90+
&& !x.is_whitespace()
91+
})
92+
.collect();
9193

9294
if let [ch] = printable.as_slice() {
9395
has_help = true;

0 commit comments

Comments
 (0)