@@ -6,7 +6,7 @@ use std::{
6
6
} ;
7
7
8
8
use rustc_lexer:: unescape:: {
9
- unescape_byte, unescape_c_string , unescape_char , unescape_literal , CStrUnit , Mode ,
9
+ unescape_byte, unescape_char , unescape_mixed , unescape_unicode , MixedUnit , Mode ,
10
10
} ;
11
11
12
12
use crate :: {
@@ -193,7 +193,7 @@ pub trait IsString: AstToken {
193
193
let text = & self . text ( ) [ text_range_no_quotes - start] ;
194
194
let offset = text_range_no_quotes. start ( ) - start;
195
195
196
- unescape_literal ( text, Self :: MODE , & mut |range, unescaped_char| {
196
+ unescape_unicode ( text, Self :: MODE , & mut |range, unescaped_char| {
197
197
let text_range =
198
198
TextRange :: new ( range. start . try_into ( ) . unwrap ( ) , range. end . try_into ( ) . unwrap ( ) ) ;
199
199
cb ( text_range + offset, unescaped_char) ;
@@ -226,7 +226,7 @@ impl ast::String {
226
226
let mut buf = String :: new ( ) ;
227
227
let mut prev_end = 0 ;
228
228
let mut has_error = false ;
229
- unescape_literal ( text, Self :: MODE , & mut |char_range, unescaped_char| match (
229
+ unescape_unicode ( text, Self :: MODE , & mut |char_range, unescaped_char| match (
230
230
unescaped_char,
231
231
buf. capacity ( ) == 0 ,
232
232
) {
@@ -270,7 +270,7 @@ impl ast::ByteString {
270
270
let mut buf: Vec < u8 > = Vec :: new ( ) ;
271
271
let mut prev_end = 0 ;
272
272
let mut has_error = false ;
273
- unescape_literal ( text, Self :: MODE , & mut |char_range, unescaped_char| match (
273
+ unescape_unicode ( text, Self :: MODE , & mut |char_range, unescaped_char| match (
274
274
unescaped_char,
275
275
buf. capacity ( ) == 0 ,
276
276
) {
@@ -311,7 +311,7 @@ impl IsString for ast::CString {
311
311
let text = & self . text ( ) [ text_range_no_quotes - start] ;
312
312
let offset = text_range_no_quotes. start ( ) - start;
313
313
314
- unescape_c_string ( text, Self :: MODE , & mut |range, unescaped_char| {
314
+ unescape_mixed ( text, Self :: MODE , & mut |range, unescaped_char| {
315
315
let text_range =
316
316
TextRange :: new ( range. start . try_into ( ) . unwrap ( ) , range. end . try_into ( ) . unwrap ( ) ) ;
317
317
// XXX: This method should only be used for highlighting ranges. The unescaped
@@ -336,12 +336,11 @@ impl ast::CString {
336
336
let mut buf = Vec :: new ( ) ;
337
337
let mut prev_end = 0 ;
338
338
let mut has_error = false ;
339
- let mut char_buf = [ 0u8 ; 4 ] ;
340
- let mut extend_unit = |buf : & mut Vec < u8 > , unit : CStrUnit | match unit {
341
- CStrUnit :: Byte ( b) => buf. push ( b) ,
342
- CStrUnit :: Char ( c) => buf. extend ( c. encode_utf8 ( & mut char_buf) . as_bytes ( ) ) ,
339
+ let extend_unit = |buf : & mut Vec < u8 > , unit : MixedUnit | match unit {
340
+ MixedUnit :: Char ( c) => buf. extend ( c. encode_utf8 ( & mut [ 0 ; 4 ] ) . as_bytes ( ) ) ,
341
+ MixedUnit :: HighByte ( b) => buf. push ( b) ,
343
342
} ;
344
- unescape_c_string ( text, Self :: MODE , & mut |char_range, unescaped| match (
343
+ unescape_mixed ( text, Self :: MODE , & mut |char_range, unescaped| match (
345
344
unescaped,
346
345
buf. capacity ( ) == 0 ,
347
346
) {
0 commit comments