@@ -7,7 +7,6 @@ mod change;
7
7
8
8
use std:: panic;
9
9
10
- use rustc_hash:: FxHashSet ;
11
10
use syntax:: { ast, Parse , SourceFile } ;
12
11
use triomphe:: Arc ;
13
12
@@ -44,12 +43,13 @@ pub trait Upcast<T: ?Sized> {
44
43
}
45
44
46
45
pub const DEFAULT_PARSE_LRU_CAP : usize = 128 ;
46
+ pub const DEFAULT_BORROWCK_LRU_CAP : usize = 256 ;
47
47
48
48
pub trait FileLoader {
49
49
/// Text of the file.
50
50
fn file_text ( & self , file_id : FileId ) -> Arc < str > ;
51
51
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 ] > ;
53
53
}
54
54
55
55
/// Database which stores all significant input facts: source code and project
@@ -84,19 +84,21 @@ pub trait SourceDatabaseExt: SourceDatabase {
84
84
#[ salsa:: input]
85
85
fn source_root ( & self , id : SourceRootId ) -> Arc < SourceRoot > ;
86
86
87
- fn source_root_crates ( & self , id : SourceRootId ) -> Arc < FxHashSet < CrateId > > ;
87
+ fn source_root_crates ( & self , id : SourceRootId ) -> Arc < [ CrateId ] > ;
88
88
}
89
89
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 ] > {
91
91
let graph = db. crate_graph ( ) ;
92
- let res = graph
92
+ let mut crates = graph
93
93
. iter ( )
94
94
. filter ( |& krate| {
95
95
let root_file = graph[ krate] . root_file_id ;
96
96
db. file_source_root ( root_file) == id
97
97
} )
98
- . collect ( ) ;
99
- Arc :: new ( res)
98
+ . collect :: < Vec < _ > > ( ) ;
99
+ crates. sort ( ) ;
100
+ crates. dedup ( ) ;
101
+ crates. into_iter ( ) . collect ( )
100
102
}
101
103
102
104
/// Silly workaround for cyclic deps between the traits
@@ -113,7 +115,7 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
113
115
source_root. resolve_path ( path)
114
116
}
115
117
116
- fn relevant_crates ( & self , file_id : FileId ) -> Arc < FxHashSet < CrateId > > {
118
+ fn relevant_crates ( & self , file_id : FileId ) -> Arc < [ CrateId ] > {
117
119
let _p = profile:: span ( "relevant_crates" ) ;
118
120
let source_root = self . 0 . file_source_root ( file_id) ;
119
121
self . 0 . source_root_crates ( source_root)
0 commit comments