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