mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Remove parse::escape_default().
str::escape_default() can be used instead.
This commit is contained in:
parent
d5d389e4f1
commit
7a56360ece
@ -298,14 +298,10 @@ pub fn char_lit(lit: &str, diag: Option<(Span, &Handler)>) -> (char, isize) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn escape_default(s: &str) -> String {
|
||||
s.chars().map(char::escape_default).flat_map(|x| x).collect()
|
||||
}
|
||||
|
||||
/// Parse a string representing a string literal into its final form. Does
|
||||
/// unescaping.
|
||||
pub fn str_lit(lit: &str, diag: Option<(Span, &Handler)>) -> String {
|
||||
debug!("parse_str_lit: given {}", escape_default(lit));
|
||||
debug!("str_lit: given {}", lit.escape_default());
|
||||
let mut res = String::with_capacity(lit.len());
|
||||
|
||||
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 {
|
||||
/// Parse a string representing a raw string literal into its final form. The
|
||||
/// only operation this does is convert embedded CRLF into a single LF.
|
||||
pub fn raw_str_lit(lit: &str) -> String {
|
||||
debug!("raw_str_lit: given {}", escape_default(lit));
|
||||
debug!("raw_str_lit: given {}", lit.escape_default());
|
||||
let mut res = String::with_capacity(lit.len());
|
||||
|
||||
let mut chars = lit.chars().peekable();
|
||||
|
@ -656,7 +656,7 @@ pub trait PrintState<'a> {
|
||||
style: ast::StrStyle) -> io::Result<()> {
|
||||
let st = match style {
|
||||
ast::StrStyle::Cooked => {
|
||||
(format!("\"{}\"", parse::escape_default(st)))
|
||||
(format!("\"{}\"", st.escape_default()))
|
||||
}
|
||||
ast::StrStyle::Raw(n) => {
|
||||
(format!("r{delim}\"{string}\"{delim}",
|
||||
|
Loading…
Reference in New Issue
Block a user