@@ -77,7 +77,7 @@ use base_db::{
7777use hir_expand:: {
7878 builtin:: { BuiltinAttrExpander , BuiltinDeriveExpander , BuiltinFnLikeExpander , EagerExpander } ,
7979 db:: ExpandDatabase ,
80- eager:: expand_eager_macro_input,
80+ eager:: { expand_eager_macro_input, expand_module_path_as_eager } ,
8181 impl_intern_lookup,
8282 name:: Name ,
8383 proc_macro:: { CustomProcMacroExpander , ProcMacroKind } ,
@@ -1400,26 +1400,19 @@ pub trait AsMacroCall {
14001400 fn as_call_id (
14011401 & self ,
14021402 db : & dyn ExpandDatabase ,
1403- krate : CrateId ,
1404- resolver : impl Fn ( & path:: ModPath ) -> Option < MacroDefId > + Copy ,
1405- ) -> Option < MacroCallId > {
1406- self . as_call_id_with_errors ( db, krate, resolver) . ok ( ) ?. value
1407- }
1408-
1409- fn as_call_id_with_errors (
1410- & self ,
1411- db : & dyn ExpandDatabase ,
1412- krate : CrateId ,
1403+ module : ModuleId ,
14131404 resolver : impl Fn ( & path:: ModPath ) -> Option < MacroDefId > + Copy ,
1405+ mod_path : impl FnOnce ( ModuleId ) -> String ,
14141406 ) -> Result < ExpandResult < Option < MacroCallId > > , UnresolvedMacro > ;
14151407}
14161408
14171409impl AsMacroCall for InFile < & ast:: MacroCall > {
1418- fn as_call_id_with_errors (
1410+ fn as_call_id (
14191411 & self ,
14201412 db : & dyn ExpandDatabase ,
1421- krate : CrateId ,
1413+ module : ModuleId ,
14221414 resolver : impl Fn ( & path:: ModPath ) -> Option < MacroDefId > + Copy ,
1415+ mod_path : impl FnOnce ( ModuleId ) -> String ,
14231416 ) -> Result < ExpandResult < Option < MacroCallId > > , UnresolvedMacro > {
14241417 let expands_to = hir_expand:: ExpandTo :: from_call_site ( self . value ) ;
14251418 let ast_id = AstId :: new ( self . file_id , db. ast_id_map ( self . file_id ) . ast_id ( self . value ) ) ;
@@ -1446,9 +1439,10 @@ impl AsMacroCall for InFile<&ast::MacroCall> {
14461439 & path,
14471440 call_site. ctx ,
14481441 expands_to,
1449- krate ,
1442+ module ,
14501443 resolver,
14511444 resolver,
1445+ mod_path,
14521446 )
14531447 }
14541448}
@@ -1475,18 +1469,20 @@ fn macro_call_as_call_id(
14751469 call : & AstIdWithPath < ast:: MacroCall > ,
14761470 call_site : SyntaxContextId ,
14771471 expand_to : ExpandTo ,
1478- krate : CrateId ,
1472+ module : ModuleId ,
14791473 resolver : impl Fn ( & path:: ModPath ) -> Option < MacroDefId > + Copy ,
1474+ mod_path : impl FnOnce ( ModuleId ) -> String ,
14801475) -> Result < Option < MacroCallId > , UnresolvedMacro > {
14811476 macro_call_as_call_id_with_eager (
14821477 db,
14831478 call. ast_id ,
14841479 & call. path ,
14851480 call_site,
14861481 expand_to,
1487- krate ,
1482+ module ,
14881483 resolver,
14891484 resolver,
1485+ mod_path,
14901486 )
14911487 . map ( |res| res. value )
14921488}
@@ -1497,16 +1493,26 @@ fn macro_call_as_call_id_with_eager(
14971493 path : & path:: ModPath ,
14981494 call_site : SyntaxContextId ,
14991495 expand_to : ExpandTo ,
1500- krate : CrateId ,
1496+ module : ModuleId ,
15011497 resolver : impl FnOnce ( & path:: ModPath ) -> Option < MacroDefId > ,
15021498 eager_resolver : impl Fn ( & path:: ModPath ) -> Option < MacroDefId > ,
1499+ mod_path : impl FnOnce ( ModuleId ) -> String ,
15031500) -> Result < ExpandResult < Option < MacroCallId > > , UnresolvedMacro > {
15041501 let def = resolver ( path) . ok_or_else ( || UnresolvedMacro { path : path. clone ( ) } ) ?;
15051502
15061503 let res = match def. kind {
1504+ MacroDefKind :: BuiltInEager ( _, EagerExpander :: ModulePath ) => expand_module_path_as_eager (
1505+ db,
1506+ module. krate ,
1507+ mod_path ( module) ,
1508+ & ast_id. to_node ( db) ,
1509+ ast_id,
1510+ def,
1511+ call_site,
1512+ ) ,
15071513 MacroDefKind :: BuiltInEager ( ..) => expand_eager_macro_input (
15081514 db,
1509- krate,
1515+ module . krate ,
15101516 & ast_id. to_node ( db) ,
15111517 ast_id,
15121518 def,
@@ -1516,7 +1522,7 @@ fn macro_call_as_call_id_with_eager(
15161522 _ if def. is_fn_like ( ) => ExpandResult {
15171523 value : Some ( def. make_call (
15181524 db,
1519- krate,
1525+ module . krate ,
15201526 MacroCallKind :: FnLike { ast_id, expand_to, eager : None } ,
15211527 call_site,
15221528 ) ) ,
0 commit comments