File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -60,10 +60,10 @@ fn test_fn_like_macro_clone_ident_subtree() {
6060fn test_fn_like_macro_clone_raw_ident ( ) {
6161 assert_expand (
6262 "fn_like_clone_tokens" ,
63- "r#\" ident \" # " ,
64- expect ! [ [ r## "
63+ "r#async " ,
64+ expect ! [ [ r#"
6565 SUBTREE $
66- LITERAL r#"ident"# 4294967295"# # ] ] ,
66+ IDENT async 4294967295"# ] ] ,
6767 ) ;
6868}
6969
Original file line number Diff line number Diff line change @@ -90,7 +90,14 @@ fn clone_tree(t: TokenTree) -> TokenTree {
9090 new. set_span ( orig. span ( ) ) ;
9191 TokenTree :: Group ( new)
9292 }
93- TokenTree :: Ident ( orig) => TokenTree :: Ident ( Ident :: new ( & orig. to_string ( ) , orig. span ( ) ) ) ,
93+ TokenTree :: Ident ( orig) => {
94+ let s = orig. to_string ( ) ;
95+ if let Some ( rest) = s. strip_prefix ( "r#" ) {
96+ TokenTree :: Ident ( Ident :: new_raw ( rest, orig. span ( ) ) )
97+ } else {
98+ TokenTree :: Ident ( Ident :: new ( & s, orig. span ( ) ) )
99+ }
100+ }
94101 TokenTree :: Punct ( orig) => {
95102 let mut new = Punct :: new ( orig. as_char ( ) , orig. spacing ( ) ) ;
96103 new. set_span ( orig. span ( ) ) ;
You can’t perform that action at this time.
0 commit comments