@@ -157,18 +157,22 @@ impl<'c> Translation<'c> {
157157
158158 // Find the first macro after the macro we're currently expanding, if any.
159159 let first_macro = macros
160- . splitn ( 2 , |macro_id| ctx. expanding_macro ( macro_id) )
160+ . splitn ( 2 , |info| {
161+ info. parameter . is_none ( ) && ctx. expanding_macro ( & info. macro_id )
162+ } )
161163 . last ( )
162164 . unwrap ( )
163- . first ( ) ;
165+ . iter ( )
166+ . filter ( |info| info. parameter . is_none ( ) )
167+ . next ( ) ;
164168 let macro_id = match first_macro {
165- Some ( macro_id ) => macro_id,
169+ Some ( info ) => info . macro_id ,
166170 None => return Ok ( None ) ,
167171 } ;
168172
169173 trace ! ( " found macro expansion: {macro_id:?}" ) ;
170174 // Ensure that we've converted this macro and that it has a valid definition.
171- let expansion = self . macro_expansions . borrow ( ) . get ( macro_id) . cloned ( ) ;
175+ let expansion = self . macro_expansions . borrow ( ) . get ( & macro_id) . cloned ( ) ;
172176 let macro_ty = match expansion {
173177 // Expansion exists.
174178 Some ( Some ( expansion) ) => expansion. ty ,
@@ -178,8 +182,8 @@ impl<'c> Translation<'c> {
178182
179183 // We haven't tried to expand it yet.
180184 None => {
181- self . convert_decl ( ctx, * macro_id) ?;
182- if let Some ( Some ( expansion) ) = self . macro_expansions . borrow ( ) . get ( macro_id) {
185+ self . convert_decl ( ctx, macro_id) ?;
186+ if let Some ( Some ( expansion) ) = self . macro_expansions . borrow ( ) . get ( & macro_id) {
183187 expansion. ty
184188 } else {
185189 return Ok ( None ) ;
@@ -189,10 +193,10 @@ impl<'c> Translation<'c> {
189193 let rust_name = self
190194 . renamer
191195 . borrow_mut ( )
192- . get ( macro_id)
196+ . get ( & macro_id)
193197 . ok_or_else ( || format_err ! ( "Macro name not declared" ) ) ?;
194198
195- self . add_import ( * macro_id, & rust_name) ;
199+ self . add_import ( macro_id, & rust_name) ;
196200
197201 let val = WithStmts :: new_val ( mk ( ) . path_expr ( vec ! [ rust_name] ) ) ;
198202
0 commit comments