Skip to content

Commit 7a56360

Browse files
committed
Remove parse::escape_default().
str::escape_default() can be used instead.
1 parent d5d389e commit 7a56360

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/libsyntax/parse/mod.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,10 @@ pub fn char_lit(lit: &str, diag: Option<(Span, &Handler)>) -> (char, isize) {
298298
}
299299
}
300300

301-
pub fn escape_default(s: &str) -> String {
302-
s.chars().map(char::escape_default).flat_map(|x| x).collect()
303-
}
304-
305301
/// Parse a string representing a string literal into its final form. Does
306302
/// unescaping.
307303
pub fn str_lit(lit: &str, diag: Option<(Span, &Handler)>) -> String {
308-
debug!("parse_str_lit: given {}", escape_default(lit));
304+
debug!("str_lit: given {}", lit.escape_default());
309305
let mut res = String::with_capacity(lit.len());
310306

311307
let error = |i| format!("lexer should have rejected {} at {}", lit, i);
@@ -374,7 +370,7 @@ pub fn str_lit(lit: &str, diag: Option<(Span, &Handler)>) -> String {
374370
/// Parse a string representing a raw string literal into its final form. The
375371
/// only operation this does is convert embedded CRLF into a single LF.
376372
pub fn raw_str_lit(lit: &str) -> String {
377-
debug!("raw_str_lit: given {}", escape_default(lit));
373+
debug!("raw_str_lit: given {}", lit.escape_default());
378374
let mut res = String::with_capacity(lit.len());
379375

380376
let mut chars = lit.chars().peekable();

src/libsyntax/print/pprust.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ pub trait PrintState<'a> {
656656
style: ast::StrStyle) -> io::Result<()> {
657657
let st = match style {
658658
ast::StrStyle::Cooked => {
659-
(format!("\"{}\"", parse::escape_default(st)))
659+
(format!("\"{}\"", st.escape_default()))
660660
}
661661
ast::StrStyle::Raw(n) => {
662662
(format!("r{delim}\"{string}\"{delim}",

0 commit comments

Comments
 (0)