@@ -77,7 +77,7 @@ use base_db::{
77
77
use hir_expand:: {
78
78
builtin:: { BuiltinAttrExpander , BuiltinDeriveExpander , BuiltinFnLikeExpander , EagerExpander } ,
79
79
db:: ExpandDatabase ,
80
- eager:: expand_eager_macro_input,
80
+ eager:: { expand_eager_macro_input, expand_module_path_as_eager } ,
81
81
impl_intern_lookup,
82
82
name:: Name ,
83
83
proc_macro:: { CustomProcMacroExpander , ProcMacroKind } ,
@@ -1400,26 +1400,19 @@ pub trait AsMacroCall {
1400
1400
fn as_call_id (
1401
1401
& self ,
1402
1402
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 ,
1413
1404
resolver : impl Fn ( & path:: ModPath ) -> Option < MacroDefId > + Copy ,
1405
+ mod_path : impl FnOnce ( ModuleId ) -> String ,
1414
1406
) -> Result < ExpandResult < Option < MacroCallId > > , UnresolvedMacro > ;
1415
1407
}
1416
1408
1417
1409
impl AsMacroCall for InFile < & ast:: MacroCall > {
1418
- fn as_call_id_with_errors (
1410
+ fn as_call_id (
1419
1411
& self ,
1420
1412
db : & dyn ExpandDatabase ,
1421
- krate : CrateId ,
1413
+ module : ModuleId ,
1422
1414
resolver : impl Fn ( & path:: ModPath ) -> Option < MacroDefId > + Copy ,
1415
+ mod_path : impl FnOnce ( ModuleId ) -> String ,
1423
1416
) -> Result < ExpandResult < Option < MacroCallId > > , UnresolvedMacro > {
1424
1417
let expands_to = hir_expand:: ExpandTo :: from_call_site ( self . value ) ;
1425
1418
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> {
1446
1439
& path,
1447
1440
call_site. ctx ,
1448
1441
expands_to,
1449
- krate ,
1442
+ module ,
1450
1443
resolver,
1451
1444
resolver,
1445
+ mod_path,
1452
1446
)
1453
1447
}
1454
1448
}
@@ -1475,18 +1469,20 @@ fn macro_call_as_call_id(
1475
1469
call : & AstIdWithPath < ast:: MacroCall > ,
1476
1470
call_site : SyntaxContextId ,
1477
1471
expand_to : ExpandTo ,
1478
- krate : CrateId ,
1472
+ module : ModuleId ,
1479
1473
resolver : impl Fn ( & path:: ModPath ) -> Option < MacroDefId > + Copy ,
1474
+ mod_path : impl FnOnce ( ModuleId ) -> String ,
1480
1475
) -> Result < Option < MacroCallId > , UnresolvedMacro > {
1481
1476
macro_call_as_call_id_with_eager (
1482
1477
db,
1483
1478
call. ast_id ,
1484
1479
& call. path ,
1485
1480
call_site,
1486
1481
expand_to,
1487
- krate ,
1482
+ module ,
1488
1483
resolver,
1489
1484
resolver,
1485
+ mod_path,
1490
1486
)
1491
1487
. map ( |res| res. value )
1492
1488
}
@@ -1497,16 +1493,26 @@ fn macro_call_as_call_id_with_eager(
1497
1493
path : & path:: ModPath ,
1498
1494
call_site : SyntaxContextId ,
1499
1495
expand_to : ExpandTo ,
1500
- krate : CrateId ,
1496
+ module : ModuleId ,
1501
1497
resolver : impl FnOnce ( & path:: ModPath ) -> Option < MacroDefId > ,
1502
1498
eager_resolver : impl Fn ( & path:: ModPath ) -> Option < MacroDefId > ,
1499
+ mod_path : impl FnOnce ( ModuleId ) -> String ,
1503
1500
) -> Result < ExpandResult < Option < MacroCallId > > , UnresolvedMacro > {
1504
1501
let def = resolver ( path) . ok_or_else ( || UnresolvedMacro { path : path. clone ( ) } ) ?;
1505
1502
1506
1503
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
+ ) ,
1507
1513
MacroDefKind :: BuiltInEager ( ..) => expand_eager_macro_input (
1508
1514
db,
1509
- krate,
1515
+ module . krate ,
1510
1516
& ast_id. to_node ( db) ,
1511
1517
ast_id,
1512
1518
def,
@@ -1516,7 +1522,7 @@ fn macro_call_as_call_id_with_eager(
1516
1522
_ if def. is_fn_like ( ) => ExpandResult {
1517
1523
value : Some ( def. make_call (
1518
1524
db,
1519
- krate,
1525
+ module . krate ,
1520
1526
MacroCallKind :: FnLike { ast_id, expand_to, eager : None } ,
1521
1527
call_site,
1522
1528
) ) ,
0 commit comments