Rollup merge of #120329 - nnethercote:3349-precursors, r=fee1-dead
RFC 3349 precursors Some cleanups I found while working on RFC 3349 that are worth landing separately. r? `@fee1-dead`
This commit is contained in:
commit
5f1f6176a5
11 changed files with 161 additions and 201 deletions
|
@ -400,7 +400,7 @@ impl<'sess, 'src> StringReader<'sess, 'src> {
|
|||
.with_code(error_code!(E0762))
|
||||
.emit()
|
||||
}
|
||||
self.cook_quoted(token::Char, Mode::Char, start, end, 1, 1) // ' '
|
||||
self.cook_unicode(token::Char, Mode::Char, start, end, 1, 1) // ' '
|
||||
}
|
||||
rustc_lexer::LiteralKind::Byte { terminated } => {
|
||||
if !terminated {
|
||||
|
@ -412,7 +412,7 @@ impl<'sess, 'src> StringReader<'sess, 'src> {
|
|||
.with_code(error_code!(E0763))
|
||||
.emit()
|
||||
}
|
||||
self.cook_quoted(token::Byte, Mode::Byte, start, end, 2, 1) // b' '
|
||||
self.cook_unicode(token::Byte, Mode::Byte, start, end, 2, 1) // b' '
|
||||
}
|
||||
rustc_lexer::LiteralKind::Str { terminated } => {
|
||||
if !terminated {
|
||||
|
@ -424,7 +424,7 @@ impl<'sess, 'src> StringReader<'sess, 'src> {
|
|||
.with_code(error_code!(E0765))
|
||||
.emit()
|
||||
}
|
||||
self.cook_quoted(token::Str, Mode::Str, start, end, 1, 1) // " "
|
||||
self.cook_unicode(token::Str, Mode::Str, start, end, 1, 1) // " "
|
||||
}
|
||||
rustc_lexer::LiteralKind::ByteStr { terminated } => {
|
||||
if !terminated {
|
||||
|
@ -436,7 +436,7 @@ impl<'sess, 'src> StringReader<'sess, 'src> {
|
|||
.with_code(error_code!(E0766))
|
||||
.emit()
|
||||
}
|
||||
self.cook_quoted(token::ByteStr, Mode::ByteStr, start, end, 2, 1) // b" "
|
||||
self.cook_unicode(token::ByteStr, Mode::ByteStr, start, end, 2, 1) // b" "
|
||||
}
|
||||
rustc_lexer::LiteralKind::CStr { terminated } => {
|
||||
if !terminated {
|
||||
|
@ -448,13 +448,13 @@ impl<'sess, 'src> StringReader<'sess, 'src> {
|
|||
.with_code(error_code!(E0767))
|
||||
.emit()
|
||||
}
|
||||
self.cook_c_string(token::CStr, Mode::CStr, start, end, 2, 1) // c" "
|
||||
self.cook_mixed(token::CStr, Mode::CStr, start, end, 2, 1) // c" "
|
||||
}
|
||||
rustc_lexer::LiteralKind::RawStr { n_hashes } => {
|
||||
if let Some(n_hashes) = n_hashes {
|
||||
let n = u32::from(n_hashes);
|
||||
let kind = token::StrRaw(n_hashes);
|
||||
self.cook_quoted(kind, Mode::RawStr, start, end, 2 + n, 1 + n) // r##" "##
|
||||
self.cook_unicode(kind, Mode::RawStr, start, end, 2 + n, 1 + n) // r##" "##
|
||||
} else {
|
||||
self.report_raw_str_error(start, 1);
|
||||
}
|
||||
|
@ -463,7 +463,7 @@ impl<'sess, 'src> StringReader<'sess, 'src> {
|
|||
if let Some(n_hashes) = n_hashes {
|
||||
let n = u32::from(n_hashes);
|
||||
let kind = token::ByteStrRaw(n_hashes);
|
||||
self.cook_quoted(kind, Mode::RawByteStr, start, end, 3 + n, 1 + n) // br##" "##
|
||||
self.cook_unicode(kind, Mode::RawByteStr, start, end, 3 + n, 1 + n) // br##" "##
|
||||
} else {
|
||||
self.report_raw_str_error(start, 2);
|
||||
}
|
||||
|
@ -472,7 +472,7 @@ impl<'sess, 'src> StringReader<'sess, 'src> {
|
|||
if let Some(n_hashes) = n_hashes {
|
||||
let n = u32::from(n_hashes);
|
||||
let kind = token::CStrRaw(n_hashes);
|
||||
self.cook_c_string(kind, Mode::RawCStr, start, end, 3 + n, 1 + n) // cr##" "##
|
||||
self.cook_unicode(kind, Mode::RawCStr, start, end, 3 + n, 1 + n) // cr##" "##
|
||||
} else {
|
||||
self.report_raw_str_error(start, 2);
|
||||
}
|
||||
|
@ -735,7 +735,7 @@ impl<'sess, 'src> StringReader<'sess, 'src> {
|
|||
}
|
||||
}
|
||||
|
||||
fn cook_quoted(
|
||||
fn cook_unicode(
|
||||
&self,
|
||||
kind: token::LitKind,
|
||||
mode: Mode,
|
||||
|
@ -745,13 +745,13 @@ impl<'sess, 'src> StringReader<'sess, 'src> {
|
|||
postfix_len: u32,
|
||||
) -> (token::LitKind, Symbol) {
|
||||
self.cook_common(kind, mode, start, end, prefix_len, postfix_len, |src, mode, callback| {
|
||||
unescape::unescape_literal(src, mode, &mut |span, result| {
|
||||
unescape::unescape_unicode(src, mode, &mut |span, result| {
|
||||
callback(span, result.map(drop))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fn cook_c_string(
|
||||
fn cook_mixed(
|
||||
&self,
|
||||
kind: token::LitKind,
|
||||
mode: Mode,
|
||||
|
@ -761,7 +761,7 @@ impl<'sess, 'src> StringReader<'sess, 'src> {
|
|||
postfix_len: u32,
|
||||
) -> (token::LitKind, Symbol) {
|
||||
self.cook_common(kind, mode, start, end, prefix_len, postfix_len, |src, mode, callback| {
|
||||
unescape::unescape_c_string(src, mode, &mut |span, result| {
|
||||
unescape::unescape_mixed(src, mode, &mut |span, result| {
|
||||
callback(span, result.map(drop))
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue