@@ -3,6 +3,7 @@ use hir::{
3
3
AsAssocItem , AssocItem , AssocItemContainer , Crate , ItemInNs , MacroDef , ModPath , Module ,
4
4
ModuleDef , Name , PathResolution , PrefixKind , ScopeDef , Semantics , SemanticsScope , Type ,
5
5
} ;
6
+ use itertools:: Itertools ;
6
7
use rustc_hash:: FxHashSet ;
7
8
use syntax:: { ast, AstNode } ;
8
9
@@ -164,16 +165,13 @@ impl<'a> ImportAssets<'a> {
164
165
& self ,
165
166
sema : & Semantics < RootDatabase > ,
166
167
prefix_kind : PrefixKind ,
167
- ) -> FxHashSet < LocatedImport > {
168
+ ) -> Vec < LocatedImport > {
168
169
let _p = profile:: span ( "import_assets::search_for_imports" ) ;
169
170
self . search_for ( sema, Some ( prefix_kind) )
170
171
}
171
172
172
173
/// This may return non-absolute paths if a part of the returned path is already imported into scope.
173
- pub fn search_for_relative_paths (
174
- & self ,
175
- sema : & Semantics < RootDatabase > ,
176
- ) -> FxHashSet < LocatedImport > {
174
+ pub fn search_for_relative_paths ( & self , sema : & Semantics < RootDatabase > ) -> Vec < LocatedImport > {
177
175
let _p = profile:: span ( "import_assets::search_for_relative_paths" ) ;
178
176
self . search_for ( sema, None )
179
177
}
@@ -182,7 +180,7 @@ impl<'a> ImportAssets<'a> {
182
180
& self ,
183
181
sema : & Semantics < RootDatabase > ,
184
182
prefixed : Option < PrefixKind > ,
185
- ) -> FxHashSet < LocatedImport > {
183
+ ) -> Vec < LocatedImport > {
186
184
let items_with_candidate_name = match self . name_to_import ( ) {
187
185
NameToImport :: Exact ( exact_name) => items_locator:: with_for_exact_name (
188
186
sema,
@@ -216,6 +214,7 @@ impl<'a> ImportAssets<'a> {
216
214
. into_iter ( )
217
215
. filter ( |import| import. import_path . len ( ) > 1 )
218
216
. filter ( |import| !scope_definitions. contains ( & ScopeDef :: from ( import. item_to_import ) ) )
217
+ . sorted_by_key ( |import| import. import_path . clone ( ) )
219
218
. collect ( )
220
219
}
221
220
0 commit comments