99// except according to those terms.
1010
1111use ast:: { Block , Crate , Ident , Mac_ , PatKind } ;
12- use ast:: { MacStmtStyle , StmtKind , ItemKind } ;
12+ use ast:: { Name , MacStmtStyle , StmtKind , ItemKind } ;
1313use ast;
1414use ext:: hygiene:: Mark ;
1515use ext:: placeholders:: { placeholder, PlaceholderExpander } ;
@@ -299,10 +299,11 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
299299 } ;
300300
301301 attr:: mark_used ( & attr) ;
302+ let name = intern ( & attr. name ( ) ) ;
302303 self . cx . bt_push ( ExpnInfo {
303304 call_site : attr. span ,
304305 callee : NameAndSpan {
305- format : MacroAttribute ( intern ( & attr . name ( ) ) ) ,
306+ format : MacroAttribute ( name) ,
306307 span : Some ( attr. span ) ,
307308 allow_internal_unstable : false ,
308309 }
@@ -325,7 +326,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
325326 let item_toks = TokenStream :: from_tts ( tts_for_item ( & item, & self . cx . parse_sess ) ) ;
326327
327328 let tok_result = mac. expand ( self . cx , attr. span , attr_toks, item_toks) ;
328- self . parse_expansion ( tok_result, kind, attr. span )
329+ self . parse_expansion ( tok_result, kind, name , attr. span )
329330 }
330331 _ => unreachable ! ( ) ,
331332 }
@@ -424,7 +425,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
424425
425426 let toks = TokenStream :: from_tts ( marked_tts) ;
426427 let tok_result = expandfun. expand ( self . cx , span, toks) ;
427- Some ( self . parse_expansion ( tok_result, kind, span) )
428+ Some ( self . parse_expansion ( tok_result, kind, extname , span) )
428429 }
429430 } ;
430431
@@ -443,7 +444,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
443444 } )
444445 }
445446
446- fn parse_expansion ( & mut self , toks : TokenStream , kind : ExpansionKind , span : Span ) -> Expansion {
447+ fn parse_expansion ( & mut self , toks : TokenStream , kind : ExpansionKind , name : Name , span : Span )
448+ -> Expansion {
447449 let mut parser = self . cx . new_parser_from_tts ( & toks. to_tts ( ) ) ;
448450 let expansion = match parser. parse_expansion ( kind, false ) {
449451 Ok ( expansion) => expansion,
@@ -452,13 +454,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
452454 return kind. dummy ( span) ;
453455 }
454456 } ;
455- parser. ensure_complete_parse ( kind == ExpansionKind :: Expr , |parser| {
456- let msg = format ! ( "macro expansion ignores token `{}` and any following" ,
457- parser. this_token_to_string( ) ) ;
458- parser. diagnostic ( ) . struct_span_err ( parser. span , & msg)
459- . span_note ( span, "caused by the macro expansion here" )
460- . emit ( ) ;
461- } ) ;
457+ parser. ensure_complete_parse ( name, kind. name ( ) , span) ;
462458 // FIXME better span info
463459 expansion. fold_with ( & mut ChangeSpan { span : span } )
464460 }
0 commit comments