@@ -332,15 +332,16 @@ pub(crate) fn parse_with_map(
332332fn macro_arg (
333333 db : & dyn ExpandDatabase ,
334334 id : MacroCallId ,
335- // FIXME: consider the following by putting fixup info into eager call info args
336- // ) -> ValueResult<Arc<(tt::Subtree, SyntaxFixupUndoInfo)>, Arc<Box<[SyntaxError]>>> {
337335) -> ValueResult < ( Arc < tt:: Subtree > , SyntaxFixupUndoInfo ) , Arc < Box < [ SyntaxError ] > > > {
338336 let loc = db. lookup_intern_macro_call ( id) ;
339- if let Some ( EagerCallInfo { arg, .. } ) = matches ! ( loc. def. kind, MacroDefKind :: BuiltInEager ( ..) )
340- . then ( || loc. eager . as_deref ( ) )
341- . flatten ( )
337+
338+ if let MacroCallLoc {
339+ def : MacroDefId { kind : MacroDefKind :: BuiltInEager ( ..) , .. } ,
340+ kind : MacroCallKind :: FnLike { eager : Some ( eager) , .. } ,
341+ ..
342+ } = & loc
342343 {
343- return ValueResult :: ok ( ( arg. clone ( ) , SyntaxFixupUndoInfo :: NONE ) ) ;
344+ return ValueResult :: ok ( ( eager . arg . clone ( ) , SyntaxFixupUndoInfo :: NONE ) ) ;
344345 }
345346
346347 let ( parse, map) = parse_with_map ( db, loc. kind . file_id ( ) ) ;
@@ -518,7 +519,7 @@ fn macro_expand(
518519) -> ExpandResult < CowArc < tt:: Subtree > > {
519520 let _p = tracing:: span!( tracing:: Level :: INFO , "macro_expand" ) . entered ( ) ;
520521
521- let ExpandResult { value : tt, mut err } = match loc. def . kind {
522+ let ExpandResult { value : tt, err } = match loc. def . kind {
522523 MacroDefKind :: ProcMacro ( ..) => return db. expand_proc_macro ( macro_call_id) . map ( CowArc :: Arc ) ,
523524 _ => {
524525 let ValueResult { value : ( macro_arg, undo_info) , err } = db. macro_arg ( macro_call_id) ;
@@ -541,23 +542,34 @@ fn macro_expand(
541542 MacroDefKind :: BuiltIn ( it, _) => {
542543 it. expand ( db, macro_call_id, arg) . map_err ( Into :: into)
543544 }
544- // This might look a bit odd, but we do not expand the inputs to eager macros here.
545- // Eager macros inputs are expanded, well, eagerly when we collect the macro calls.
546- // That kind of expansion uses the ast id map of an eager macros input though which goes through
547- // the HirFileId machinery. As eager macro inputs are assigned a macro file id that query
548- // will end up going through here again, whereas we want to just want to inspect the raw input.
549- // As such we just return the input subtree here.
550- MacroDefKind :: BuiltInEager ( ..) if loc. eager . is_none ( ) => {
551- return ExpandResult {
552- value : CowArc :: Arc ( macro_arg. clone ( ) ) ,
553- err : err. map ( format_parse_err) ,
554- } ;
555- }
556545 MacroDefKind :: BuiltInDerive ( it, _) => {
557546 it. expand ( db, macro_call_id, arg) . map_err ( Into :: into)
558547 }
559548 MacroDefKind :: BuiltInEager ( it, _) => {
560- it. expand ( db, macro_call_id, arg) . map_err ( Into :: into)
549+ // This might look a bit odd, but we do not expand the inputs to eager macros here.
550+ // Eager macros inputs are expanded, well, eagerly when we collect the macro calls.
551+ // That kind of expansion uses the ast id map of an eager macros input though which goes through
552+ // the HirFileId machinery. As eager macro inputs are assigned a macro file id that query
553+ // will end up going through here again, whereas we want to just want to inspect the raw input.
554+ // As such we just return the input subtree here.
555+ let eager = match & loc. kind {
556+ MacroCallKind :: FnLike { eager : None , .. } => {
557+ return ExpandResult {
558+ value : CowArc :: Arc ( macro_arg. clone ( ) ) ,
559+ err : err. map ( format_parse_err) ,
560+ } ;
561+ }
562+ MacroCallKind :: FnLike { eager : Some ( eager) , .. } => Some ( & * * eager) ,
563+ _ => None ,
564+ } ;
565+
566+ let mut res = it. expand ( db, macro_call_id, arg) . map_err ( Into :: into) ;
567+
568+ if let Some ( EagerCallInfo { error, .. } ) = eager {
569+ // FIXME: We should report both errors!
570+ res. err = error. clone ( ) . or ( res. err ) ;
571+ }
572+ res
561573 }
562574 MacroDefKind :: BuiltInAttr ( it, _) => {
563575 let mut res = it. expand ( db, macro_call_id, arg) ;
@@ -574,11 +586,6 @@ fn macro_expand(
574586 }
575587 } ;
576588
577- if let Some ( EagerCallInfo { error, .. } ) = loc. eager . as_deref ( ) {
578- // FIXME: We should report both errors!
579- err = error. clone ( ) . or ( err) ;
580- }
581-
582589 // Skip checking token tree limit for include! macro call
583590 if !loc. def . is_include ( ) {
584591 // Set a hard limit for the expanded tt
0 commit comments