@@ -12,7 +12,7 @@ use span::{Edition, FileId, Span};
12
12
use stdx:: format_to;
13
13
use syntax:: {
14
14
format_smolstr,
15
- unescape:: { Mode , unescape_byte, unescape_char, unescape_unicode } ,
15
+ unescape:: { unescape_byte, unescape_char, unescape_str } ,
16
16
} ;
17
17
use syntax_bridge:: syntax_node_to_token_tree;
18
18
@@ -422,15 +422,12 @@ fn compile_error_expand(
422
422
span : Span ,
423
423
) -> ExpandResult < tt:: TopSubtree > {
424
424
let err = match & * tt. 0 {
425
- [
426
- _,
427
- tt:: TokenTree :: Leaf ( tt:: Leaf :: Literal ( tt:: Literal {
428
- symbol : text,
429
- span : _,
430
- kind : tt:: LitKind :: Str | tt:: LitKind :: StrRaw ( _) ,
431
- suffix : _,
432
- } ) ) ,
433
- ] => ExpandError :: other ( span, Box :: from ( unescape_str ( text) . as_str ( ) ) ) ,
425
+ [ _, tt:: TokenTree :: Leaf ( tt:: Leaf :: Literal ( tt:: Literal {
426
+ symbol : text,
427
+ span : _,
428
+ kind : tt:: LitKind :: Str | tt:: LitKind :: StrRaw ( _) ,
429
+ suffix : _,
430
+ } ) ) ] => ExpandError :: other ( span, Box :: from ( unescape_symbol ( text) . as_str ( ) ) ) ,
434
431
_ => ExpandError :: other ( span, "`compile_error!` argument must be a string" ) ,
435
432
} ;
436
433
@@ -481,7 +478,7 @@ fn concat_expand(
481
478
format_to ! ( text, "{}" , it. symbol. as_str( ) )
482
479
}
483
480
tt:: LitKind :: Str => {
484
- text. push_str ( unescape_str ( & it. symbol ) . as_str ( ) ) ;
481
+ text. push_str ( unescape_symbol ( & it. symbol ) . as_str ( ) ) ;
485
482
record_span ( it. span ) ;
486
483
}
487
484
tt:: LitKind :: StrRaw ( _) => {
@@ -691,7 +688,7 @@ fn parse_string(tt: &tt::TopSubtree) -> Result<(Symbol, Span), ExpandError> {
691
688
span,
692
689
kind : tt:: LitKind :: Str ,
693
690
suffix : _,
694
- } ) ) => Ok ( ( unescape_str ( text) , * span) ) ,
691
+ } ) ) => Ok ( ( unescape_symbol ( text) , * span) ) ,
695
692
TtElement :: Leaf ( tt:: Leaf :: Literal ( tt:: Literal {
696
693
symbol : text,
697
694
span,
@@ -712,7 +709,7 @@ fn parse_string(tt: &tt::TopSubtree) -> Result<(Symbol, Span), ExpandError> {
712
709
span,
713
710
kind : tt:: LitKind :: Str ,
714
711
suffix : _,
715
- } ) ) => Some ( ( unescape_str ( text) , * span) ) ,
712
+ } ) ) => Some ( ( unescape_symbol ( text) , * span) ) ,
716
713
TtElement :: Leaf ( tt:: Leaf :: Literal ( tt:: Literal {
717
714
symbol : text,
718
715
span,
@@ -897,11 +894,11 @@ fn quote_expand(
897
894
)
898
895
}
899
896
900
- fn unescape_str ( s : & Symbol ) -> Symbol {
897
+ fn unescape_symbol ( s : & Symbol ) -> Symbol {
901
898
if s. as_str ( ) . contains ( '\\' ) {
902
899
let s = s. as_str ( ) ;
903
900
let mut buf = String :: with_capacity ( s. len ( ) ) ;
904
- unescape_unicode ( s, Mode :: Str , & mut |_, c| {
901
+ unescape_str ( s, |_, c| {
905
902
if let Ok ( c) = c {
906
903
buf. push ( c)
907
904
}
0 commit comments