@@ -7,7 +7,6 @@ mod change;
77
88use std:: panic;
99
10- use rustc_hash:: FxHashSet ;
1110use syntax:: { ast, Parse , SourceFile } ;
1211use triomphe:: Arc ;
1312
@@ -44,12 +43,13 @@ pub trait Upcast<T: ?Sized> {
4443}
4544
4645pub const DEFAULT_PARSE_LRU_CAP : usize = 128 ;
46+ pub const DEFAULT_BORROWCK_LRU_CAP : usize = 256 ;
4747
4848pub trait FileLoader {
4949 /// Text of the file.
5050 fn file_text ( & self , file_id : FileId ) -> Arc < str > ;
5151 fn resolve_path ( & self , path : AnchoredPath < ' _ > ) -> Option < FileId > ;
52- fn relevant_crates ( & self , file_id : FileId ) -> Arc < FxHashSet < CrateId > > ;
52+ fn relevant_crates ( & self , file_id : FileId ) -> Arc < [ CrateId ] > ;
5353}
5454
5555/// Database which stores all significant input facts: source code and project
@@ -84,19 +84,21 @@ pub trait SourceDatabaseExt: SourceDatabase {
8484 #[ salsa:: input]
8585 fn source_root ( & self , id : SourceRootId ) -> Arc < SourceRoot > ;
8686
87- fn source_root_crates ( & self , id : SourceRootId ) -> Arc < FxHashSet < CrateId > > ;
87+ fn source_root_crates ( & self , id : SourceRootId ) -> Arc < [ CrateId ] > ;
8888}
8989
90- fn source_root_crates ( db : & dyn SourceDatabaseExt , id : SourceRootId ) -> Arc < FxHashSet < CrateId > > {
90+ fn source_root_crates ( db : & dyn SourceDatabaseExt , id : SourceRootId ) -> Arc < [ CrateId ] > {
9191 let graph = db. crate_graph ( ) ;
92- let res = graph
92+ let mut crates = graph
9393 . iter ( )
9494 . filter ( |& krate| {
9595 let root_file = graph[ krate] . root_file_id ;
9696 db. file_source_root ( root_file) == id
9797 } )
98- . collect ( ) ;
99- Arc :: new ( res)
98+ . collect :: < Vec < _ > > ( ) ;
99+ crates. sort ( ) ;
100+ crates. dedup ( ) ;
101+ crates. into_iter ( ) . collect ( )
100102}
101103
102104/// Silly workaround for cyclic deps between the traits
@@ -113,7 +115,7 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
113115 source_root. resolve_path ( path)
114116 }
115117
116- fn relevant_crates ( & self , file_id : FileId ) -> Arc < FxHashSet < CrateId > > {
118+ fn relevant_crates ( & self , file_id : FileId ) -> Arc < [ CrateId ] > {
117119 let _p = profile:: span ( "relevant_crates" ) ;
118120 let source_root = self . 0 . file_source_root ( file_id) ;
119121 self . 0 . source_root_crates ( source_root)
0 commit comments