66//! actual IO. See `vfs` and `project_model` in the `rust-analyzer` crate for how
77//! actual IO is done and lowered to input.
88
9- use std:: { fmt, ops, panic:: RefUnwindSafe , str:: FromStr , sync:: Arc } ;
9+ use std:: { fmt, mem , ops, panic:: RefUnwindSafe , str:: FromStr , sync:: Arc } ;
1010
1111use cfg:: CfgOptions ;
1212use rustc_hash:: FxHashMap ;
1313use stdx:: hash:: { NoHashHashMap , NoHashHashSet } ;
1414use syntax:: SmolStr ;
1515use 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 > ;
1720
1821/// Files are grouped into source roots. A source root is a directory on the
1922/// file systems which is watched for changes. Typically it corresponds to a
@@ -269,7 +272,6 @@ pub struct CrateData {
269272 pub target_layout : TargetLayoutLoadResult ,
270273 pub env : Env ,
271274 pub dependencies : Vec < Dependency > ,
272- pub proc_macro : ProcMacroLoadResult ,
273275 pub origin : CrateOrigin ,
274276 pub is_proc_macro : bool ,
275277}
@@ -322,7 +324,6 @@ impl CrateGraph {
322324 cfg_options : CfgOptions ,
323325 potential_cfg_options : CfgOptions ,
324326 env : Env ,
325- proc_macro : ProcMacroLoadResult ,
326327 is_proc_macro : bool ,
327328 origin : CrateOrigin ,
328329 target_layout : Result < Arc < str > , Arc < str > > ,
@@ -335,7 +336,6 @@ impl CrateGraph {
335336 cfg_options,
336337 potential_cfg_options,
337338 env,
338- proc_macro,
339339 dependencies : Vec :: new ( ) ,
340340 origin,
341341 target_layout,
@@ -456,11 +456,11 @@ impl CrateGraph {
456456 }
457457
458458 /// Extends this crate graph by adding a complete disjoint second crate
459- /// graph.
459+ /// graph and adjust the ids in the [`ProcMacroPaths`] accordingly .
460460 ///
461461 /// The ids of the crates in the `other` graph are shifted by the return
462462 /// amount.
463- pub fn extend ( & mut self , other : CrateGraph ) -> u32 {
463+ pub fn extend ( & mut self , other : CrateGraph , proc_macros : & mut ProcMacroPaths ) -> u32 {
464464 let start = self . arena . len ( ) as u32 ;
465465 self . arena . extend ( other. arena . into_iter ( ) . map ( |( id, mut data) | {
466466 let new_id = id. shift ( start) ;
@@ -469,6 +469,11 @@ impl CrateGraph {
469469 }
470470 ( new_id, data)
471471 } ) ) ;
472+
473+ * proc_macros = mem:: take ( proc_macros)
474+ . into_iter ( )
475+ . map ( |( id, macros) | ( id. shift ( start) , macros) )
476+ . collect ( ) ;
472477 start
473478 }
474479
@@ -645,7 +650,6 @@ mod tests {
645650 CfgOptions :: default ( ) ,
646651 CfgOptions :: default ( ) ,
647652 Env :: default ( ) ,
648- Ok ( Vec :: new ( ) ) ,
649653 false ,
650654 CrateOrigin :: CratesIo { repo : None , name : None } ,
651655 Err ( "" . into ( ) ) ,
@@ -658,7 +662,6 @@ mod tests {
658662 CfgOptions :: default ( ) ,
659663 CfgOptions :: default ( ) ,
660664 Env :: default ( ) ,
661- Ok ( Vec :: new ( ) ) ,
662665 false ,
663666 CrateOrigin :: CratesIo { repo : None , name : None } ,
664667 Err ( "" . into ( ) ) ,
@@ -671,7 +674,6 @@ mod tests {
671674 CfgOptions :: default ( ) ,
672675 CfgOptions :: default ( ) ,
673676 Env :: default ( ) ,
674- Ok ( Vec :: new ( ) ) ,
675677 false ,
676678 CrateOrigin :: CratesIo { repo : None , name : None } ,
677679 Err ( "" . into ( ) ) ,
@@ -698,7 +700,6 @@ mod tests {
698700 CfgOptions :: default ( ) ,
699701 CfgOptions :: default ( ) ,
700702 Env :: default ( ) ,
701- Ok ( Vec :: new ( ) ) ,
702703 false ,
703704 CrateOrigin :: CratesIo { repo : None , name : None } ,
704705 Err ( "" . into ( ) ) ,
@@ -711,7 +712,6 @@ mod tests {
711712 CfgOptions :: default ( ) ,
712713 CfgOptions :: default ( ) ,
713714 Env :: default ( ) ,
714- Ok ( Vec :: new ( ) ) ,
715715 false ,
716716 CrateOrigin :: CratesIo { repo : None , name : None } ,
717717 Err ( "" . into ( ) ) ,
@@ -735,7 +735,6 @@ mod tests {
735735 CfgOptions :: default ( ) ,
736736 CfgOptions :: default ( ) ,
737737 Env :: default ( ) ,
738- Ok ( Vec :: new ( ) ) ,
739738 false ,
740739 CrateOrigin :: CratesIo { repo : None , name : None } ,
741740 Err ( "" . into ( ) ) ,
@@ -748,7 +747,6 @@ mod tests {
748747 CfgOptions :: default ( ) ,
749748 CfgOptions :: default ( ) ,
750749 Env :: default ( ) ,
751- Ok ( Vec :: new ( ) ) ,
752750 false ,
753751 CrateOrigin :: CratesIo { repo : None , name : None } ,
754752 Err ( "" . into ( ) ) ,
@@ -761,7 +759,6 @@ mod tests {
761759 CfgOptions :: default ( ) ,
762760 CfgOptions :: default ( ) ,
763761 Env :: default ( ) ,
764- Ok ( Vec :: new ( ) ) ,
765762 false ,
766763 CrateOrigin :: CratesIo { repo : None , name : None } ,
767764 Err ( "" . into ( ) ) ,
@@ -785,7 +782,6 @@ mod tests {
785782 CfgOptions :: default ( ) ,
786783 CfgOptions :: default ( ) ,
787784 Env :: default ( ) ,
788- Ok ( Vec :: new ( ) ) ,
789785 false ,
790786 CrateOrigin :: CratesIo { repo : None , name : None } ,
791787 Err ( "" . into ( ) ) ,
@@ -798,7 +794,6 @@ mod tests {
798794 CfgOptions :: default ( ) ,
799795 CfgOptions :: default ( ) ,
800796 Env :: default ( ) ,
801- Ok ( Vec :: new ( ) ) ,
802797 false ,
803798 CrateOrigin :: CratesIo { repo : None , name : None } ,
804799 Err ( "" . into ( ) ) ,
0 commit comments