6
6
//! actual IO. See `vfs` and `project_model` in the `rust-analyzer` crate for how
7
7
//! actual IO is done and lowered to input.
8
8
9
- use std:: { fmt, ops, panic:: RefUnwindSafe , str:: FromStr , sync:: Arc } ;
9
+ use std:: { fmt, mem , ops, panic:: RefUnwindSafe , str:: FromStr , sync:: Arc } ;
10
10
11
11
use cfg:: CfgOptions ;
12
12
use rustc_hash:: FxHashMap ;
13
13
use stdx:: hash:: { NoHashHashMap , NoHashHashSet } ;
14
14
use syntax:: SmolStr ;
15
15
use tt:: token_id:: Subtree ;
16
- use vfs:: { file_set:: FileSet , AnchoredPath , FileId , VfsPath } ;
16
+ use vfs:: { file_set:: FileSet , AbsPathBuf , AnchoredPath , FileId , VfsPath } ;
17
+
18
+ pub type ProcMacroPaths = FxHashMap < CrateId , Result < ( Option < String > , AbsPathBuf ) , String > > ;
19
+ pub type ProcMacros = FxHashMap < CrateId , ProcMacroLoadResult > ;
17
20
18
21
/// Files are grouped into source roots. A source root is a directory on the
19
22
/// file systems which is watched for changes. Typically it corresponds to a
@@ -269,7 +272,6 @@ pub struct CrateData {
269
272
pub target_layout : TargetLayoutLoadResult ,
270
273
pub env : Env ,
271
274
pub dependencies : Vec < Dependency > ,
272
- pub proc_macro : ProcMacroLoadResult ,
273
275
pub origin : CrateOrigin ,
274
276
pub is_proc_macro : bool ,
275
277
}
@@ -322,7 +324,6 @@ impl CrateGraph {
322
324
cfg_options : CfgOptions ,
323
325
potential_cfg_options : CfgOptions ,
324
326
env : Env ,
325
- proc_macro : ProcMacroLoadResult ,
326
327
is_proc_macro : bool ,
327
328
origin : CrateOrigin ,
328
329
target_layout : Result < Arc < str > , Arc < str > > ,
@@ -335,7 +336,6 @@ impl CrateGraph {
335
336
cfg_options,
336
337
potential_cfg_options,
337
338
env,
338
- proc_macro,
339
339
dependencies : Vec :: new ( ) ,
340
340
origin,
341
341
target_layout,
@@ -456,11 +456,11 @@ impl CrateGraph {
456
456
}
457
457
458
458
/// Extends this crate graph by adding a complete disjoint second crate
459
- /// graph.
459
+ /// graph and adjust the ids in the [`ProcMacroPaths`] accordingly .
460
460
///
461
461
/// The ids of the crates in the `other` graph are shifted by the return
462
462
/// amount.
463
- pub fn extend ( & mut self , other : CrateGraph ) -> u32 {
463
+ pub fn extend ( & mut self , other : CrateGraph , proc_macros : & mut ProcMacroPaths ) -> u32 {
464
464
let start = self . arena . len ( ) as u32 ;
465
465
self . arena . extend ( other. arena . into_iter ( ) . map ( |( id, mut data) | {
466
466
let new_id = id. shift ( start) ;
@@ -469,6 +469,11 @@ impl CrateGraph {
469
469
}
470
470
( new_id, data)
471
471
} ) ) ;
472
+
473
+ * proc_macros = mem:: take ( proc_macros)
474
+ . into_iter ( )
475
+ . map ( |( id, macros) | ( id. shift ( start) , macros) )
476
+ . collect ( ) ;
472
477
start
473
478
}
474
479
@@ -645,7 +650,6 @@ mod tests {
645
650
CfgOptions :: default ( ) ,
646
651
CfgOptions :: default ( ) ,
647
652
Env :: default ( ) ,
648
- Ok ( Vec :: new ( ) ) ,
649
653
false ,
650
654
CrateOrigin :: CratesIo { repo : None , name : None } ,
651
655
Err ( "" . into ( ) ) ,
@@ -658,7 +662,6 @@ mod tests {
658
662
CfgOptions :: default ( ) ,
659
663
CfgOptions :: default ( ) ,
660
664
Env :: default ( ) ,
661
- Ok ( Vec :: new ( ) ) ,
662
665
false ,
663
666
CrateOrigin :: CratesIo { repo : None , name : None } ,
664
667
Err ( "" . into ( ) ) ,
@@ -671,7 +674,6 @@ mod tests {
671
674
CfgOptions :: default ( ) ,
672
675
CfgOptions :: default ( ) ,
673
676
Env :: default ( ) ,
674
- Ok ( Vec :: new ( ) ) ,
675
677
false ,
676
678
CrateOrigin :: CratesIo { repo : None , name : None } ,
677
679
Err ( "" . into ( ) ) ,
@@ -698,7 +700,6 @@ mod tests {
698
700
CfgOptions :: default ( ) ,
699
701
CfgOptions :: default ( ) ,
700
702
Env :: default ( ) ,
701
- Ok ( Vec :: new ( ) ) ,
702
703
false ,
703
704
CrateOrigin :: CratesIo { repo : None , name : None } ,
704
705
Err ( "" . into ( ) ) ,
@@ -711,7 +712,6 @@ mod tests {
711
712
CfgOptions :: default ( ) ,
712
713
CfgOptions :: default ( ) ,
713
714
Env :: default ( ) ,
714
- Ok ( Vec :: new ( ) ) ,
715
715
false ,
716
716
CrateOrigin :: CratesIo { repo : None , name : None } ,
717
717
Err ( "" . into ( ) ) ,
@@ -735,7 +735,6 @@ mod tests {
735
735
CfgOptions :: default ( ) ,
736
736
CfgOptions :: default ( ) ,
737
737
Env :: default ( ) ,
738
- Ok ( Vec :: new ( ) ) ,
739
738
false ,
740
739
CrateOrigin :: CratesIo { repo : None , name : None } ,
741
740
Err ( "" . into ( ) ) ,
@@ -748,7 +747,6 @@ mod tests {
748
747
CfgOptions :: default ( ) ,
749
748
CfgOptions :: default ( ) ,
750
749
Env :: default ( ) ,
751
- Ok ( Vec :: new ( ) ) ,
752
750
false ,
753
751
CrateOrigin :: CratesIo { repo : None , name : None } ,
754
752
Err ( "" . into ( ) ) ,
@@ -761,7 +759,6 @@ mod tests {
761
759
CfgOptions :: default ( ) ,
762
760
CfgOptions :: default ( ) ,
763
761
Env :: default ( ) ,
764
- Ok ( Vec :: new ( ) ) ,
765
762
false ,
766
763
CrateOrigin :: CratesIo { repo : None , name : None } ,
767
764
Err ( "" . into ( ) ) ,
@@ -785,7 +782,6 @@ mod tests {
785
782
CfgOptions :: default ( ) ,
786
783
CfgOptions :: default ( ) ,
787
784
Env :: default ( ) ,
788
- Ok ( Vec :: new ( ) ) ,
789
785
false ,
790
786
CrateOrigin :: CratesIo { repo : None , name : None } ,
791
787
Err ( "" . into ( ) ) ,
@@ -798,7 +794,6 @@ mod tests {
798
794
CfgOptions :: default ( ) ,
799
795
CfgOptions :: default ( ) ,
800
796
Env :: default ( ) ,
801
- Ok ( Vec :: new ( ) ) ,
802
797
false ,
803
798
CrateOrigin :: CratesIo { repo : None , name : None } ,
804
799
Err ( "" . into ( ) ) ,
0 commit comments