@@ -6,7 +6,7 @@ use std::{
66} ;
77
88use 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 ,
1010} ;
1111
1212use crate :: {
@@ -193,7 +193,7 @@ pub trait IsString: AstToken {
193193 let text = & self . text ( ) [ text_range_no_quotes - start] ;
194194 let offset = text_range_no_quotes. start ( ) - start;
195195
196- unescape_literal ( text, Self :: MODE , & mut |range, unescaped_char| {
196+ unescape_unicode ( text, Self :: MODE , & mut |range, unescaped_char| {
197197 let text_range =
198198 TextRange :: new ( range. start . try_into ( ) . unwrap ( ) , range. end . try_into ( ) . unwrap ( ) ) ;
199199 cb ( text_range + offset, unescaped_char) ;
@@ -226,7 +226,7 @@ impl ast::String {
226226 let mut buf = String :: new ( ) ;
227227 let mut prev_end = 0 ;
228228 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 (
230230 unescaped_char,
231231 buf. capacity ( ) == 0 ,
232232 ) {
@@ -270,7 +270,7 @@ impl ast::ByteString {
270270 let mut buf: Vec < u8 > = Vec :: new ( ) ;
271271 let mut prev_end = 0 ;
272272 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 (
274274 unescaped_char,
275275 buf. capacity ( ) == 0 ,
276276 ) {
@@ -311,7 +311,7 @@ impl IsString for ast::CString {
311311 let text = & self . text ( ) [ text_range_no_quotes - start] ;
312312 let offset = text_range_no_quotes. start ( ) - start;
313313
314- unescape_c_string ( text, Self :: MODE , & mut |range, unescaped_char| {
314+ unescape_mixed ( text, Self :: MODE , & mut |range, unescaped_char| {
315315 let text_range =
316316 TextRange :: new ( range. start . try_into ( ) . unwrap ( ) , range. end . try_into ( ) . unwrap ( ) ) ;
317317 // XXX: This method should only be used for highlighting ranges. The unescaped
@@ -336,12 +336,11 @@ impl ast::CString {
336336 let mut buf = Vec :: new ( ) ;
337337 let mut prev_end = 0 ;
338338 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) ,
343342 } ;
344- unescape_c_string ( text, Self :: MODE , & mut |char_range, unescaped| match (
343+ unescape_mixed ( text, Self :: MODE , & mut |char_range, unescaped| match (
345344 unescaped,
346345 buf. capacity ( ) == 0 ,
347346 ) {
0 commit comments