@@ -79,33 +79,35 @@ pub fn expand_eager_macro_input(
79
79
return Ok ( ExpandResult { value : None , err } ) ;
80
80
} ;
81
81
82
- let og_tmap = mbe:: syntax_node_to_token_map (
83
- macro_call. value . token_tree ( ) . expect ( "macro_arg_text succeeded" ) . syntax ( ) ,
84
- ) ;
85
-
86
82
let ( mut subtree, expanded_eager_input_token_map) =
87
83
mbe:: syntax_node_to_token_tree ( & expanded_eager_input) ;
88
84
89
- // The tokenmap and ids of subtree point into the expanded syntax node, but that is inaccessible from the outside
90
- // so we need to remap them to the original input of the eager macro.
91
- subtree. visit_ids ( & |id| {
92
- // Note: we discard all token ids of braces and the like here, but that's not too bad and only a temporary fix
85
+ let og_tmap = if let Some ( tt) = macro_call. value . token_tree ( ) {
86
+ let og_tmap = mbe:: syntax_node_to_token_map ( tt. syntax ( ) ) ;
87
+ // The tokenmap and ids of subtree point into the expanded syntax node, but that is inaccessible from the outside
88
+ // so we need to remap them to the original input of the eager macro.
89
+ subtree. visit_ids ( & |id| {
90
+ // Note: we discard all token ids of braces and the like here, but that's not too bad and only a temporary fix
93
91
94
- if let Some ( range) =
95
- expanded_eager_input_token_map. first_range_by_token ( id, syntax:: SyntaxKind :: TOMBSTONE )
96
- {
97
- // remap from expanded eager input to eager input expansion
98
- if let Some ( og_range) = mapping. get ( & range) {
99
- // remap from eager input expansion to original eager input
100
- if let Some ( & og_range) = ws_mapping. get ( og_range) {
101
- if let Some ( og_token) = og_tmap. token_by_range ( og_range) {
102
- return og_token;
92
+ if let Some ( range) = expanded_eager_input_token_map
93
+ . first_range_by_token ( id, syntax:: SyntaxKind :: TOMBSTONE )
94
+ {
95
+ // remap from expanded eager input to eager input expansion
96
+ if let Some ( og_range) = mapping. get ( & range) {
97
+ // remap from eager input expansion to original eager input
98
+ if let Some ( & og_range) = ws_mapping. get ( og_range) {
99
+ if let Some ( og_token) = og_tmap. token_by_range ( og_range) {
100
+ return og_token;
101
+ }
103
102
}
104
103
}
105
104
}
106
- }
107
- tt:: TokenId :: UNSPECIFIED
108
- } ) ;
105
+ tt:: TokenId :: UNSPECIFIED
106
+ } ) ;
107
+ og_tmap
108
+ } else {
109
+ Default :: default ( )
110
+ } ;
109
111
subtree. delimiter = crate :: tt:: Delimiter :: unspecified ( ) ;
110
112
111
113
let loc = MacroCallLoc {
0 commit comments