@@ -273,12 +273,13 @@ impl ImportAssets {
273
273
Some ( it) => it,
274
274
None => return <FxIndexSet < _ > >:: default ( ) . into_iter ( ) ,
275
275
} ;
276
+ let db = sema. db ;
276
277
let krate = self . module_with_candidate . krate ( ) ;
277
278
let scope_definitions = self . scope_definitions ( sema) ;
278
279
let mod_path = |item| {
279
280
get_mod_path (
280
- sema . db ,
281
- item_for_path_search ( sema . db , item) ?,
281
+ db,
282
+ item_for_path_search ( db, item) ?,
282
283
& self . module_with_candidate ,
283
284
prefixed,
284
285
cfg,
@@ -288,7 +289,7 @@ impl ImportAssets {
288
289
289
290
match & self . import_candidate {
290
291
ImportCandidate :: Path ( path_candidate) => path_applicable_imports (
291
- sema ,
292
+ db ,
292
293
& scope,
293
294
krate,
294
295
path_candidate,
@@ -297,7 +298,7 @@ impl ImportAssets {
297
298
) ,
298
299
ImportCandidate :: TraitAssocItem ( trait_candidate)
299
300
| ImportCandidate :: TraitMethod ( trait_candidate) => trait_applicable_items (
300
- sema ,
301
+ db ,
301
302
krate,
302
303
& scope,
303
304
trait_candidate,
@@ -325,7 +326,7 @@ impl ImportAssets {
325
326
}
326
327
327
328
fn path_applicable_imports (
328
- sema : & Semantics < ' _ , RootDatabase > ,
329
+ db : & RootDatabase ,
329
330
scope : & SemanticsScope < ' _ > ,
330
331
current_crate : Crate ,
331
332
path_candidate : & PathImportCandidate ,
@@ -337,7 +338,7 @@ fn path_applicable_imports(
337
338
match & * path_candidate. qualifier {
338
339
[ ] => {
339
340
items_locator:: items_with_name (
340
- sema ,
341
+ db ,
341
342
current_crate,
342
343
path_candidate. name . clone ( ) ,
343
344
// FIXME: we could look up assoc items by the input and propose those in completion,
@@ -365,7 +366,7 @@ fn path_applicable_imports(
365
366
// what follows
366
367
// FIXME: This doesn't handle visibility
367
368
[ first_qsegment, qualifier_rest @ ..] => items_locator:: items_with_name (
368
- sema ,
369
+ db ,
369
370
current_crate,
370
371
NameToImport :: Exact ( first_qsegment. as_str ( ) . to_owned ( ) , true ) ,
371
372
AssocSearchMode :: Exclude ,
@@ -374,7 +375,7 @@ fn path_applicable_imports(
374
375
// we found imports for `first_qsegment`, now we need to filter these imports by whether
375
376
// they result in resolving the rest of the path successfully
376
377
validate_resolvable (
377
- sema ,
378
+ db ,
378
379
scope,
379
380
mod_path,
380
381
scope_filter,
@@ -391,7 +392,7 @@ fn path_applicable_imports(
391
392
/// Validates and builds an import for `resolved_qualifier` if the `unresolved_qualifier` appended
392
393
/// to it resolves and there is a validate `candidate` after that.
393
394
fn validate_resolvable (
394
- sema : & Semantics < ' _ , RootDatabase > ,
395
+ db : & RootDatabase ,
395
396
scope : & SemanticsScope < ' _ > ,
396
397
mod_path : impl Fn ( ItemInNs ) -> Option < ModPath > ,
397
398
scope_filter : impl Fn ( ItemInNs ) -> bool ,
@@ -406,8 +407,8 @@ fn validate_resolvable(
406
407
if !unresolved_qualifier. is_empty ( ) {
407
408
match resolved_qualifier {
408
409
ItemInNs :: Types ( ModuleDef :: Module ( module) ) => {
409
- adjusted_resolved_qualifier = sema
410
- . resolve_mod_path_relative ( module , unresolved_qualifier. iter ( ) . cloned ( ) ) ?
410
+ adjusted_resolved_qualifier = module
411
+ . resolve_mod_path ( db , unresolved_qualifier. iter ( ) . cloned ( ) ) ?
411
412
. next ( ) ?;
412
413
}
413
414
// can't resolve multiple segments for non-module item path bases
@@ -424,7 +425,7 @@ fn validate_resolvable(
424
425
let ty = match qualifier {
425
426
ModuleDef :: Module ( module) => {
426
427
return items_locator:: items_with_name_in_module (
427
- sema ,
428
+ db ,
428
429
module,
429
430
candidate. clone ( ) ,
430
431
AssocSearchMode :: Exclude ,
@@ -439,17 +440,17 @@ fn validate_resolvable(
439
440
ModuleDef :: Trait ( _) => return None ,
440
441
// FIXME
441
442
ModuleDef :: TraitAlias ( _) => return None ,
442
- ModuleDef :: TypeAlias ( alias) => alias. ty ( sema . db ) ,
443
- ModuleDef :: BuiltinType ( builtin) => builtin. ty ( sema . db ) ,
444
- ModuleDef :: Adt ( adt) => adt. ty ( sema . db ) ,
443
+ ModuleDef :: TypeAlias ( alias) => alias. ty ( db) ,
444
+ ModuleDef :: BuiltinType ( builtin) => builtin. ty ( db) ,
445
+ ModuleDef :: Adt ( adt) => adt. ty ( db) ,
445
446
_ => return None ,
446
447
} ;
447
- ty. iterate_path_candidates ( sema . db , scope, & FxHashSet :: default ( ) , None , None , |assoc| {
448
+ ty. iterate_path_candidates ( db, scope, & FxHashSet :: default ( ) , None , None , |assoc| {
448
449
// FIXME: Support extra trait imports
449
- if assoc. container_or_implemented_trait ( sema . db ) . is_some ( ) {
450
+ if assoc. container_or_implemented_trait ( db) . is_some ( ) {
450
451
return None ;
451
452
}
452
- let name = assoc. name ( sema . db ) ?;
453
+ let name = assoc. name ( db) ?;
453
454
let is_match = match candidate {
454
455
NameToImport :: Prefix ( text, true ) => name. as_str ( ) . starts_with ( text) ,
455
456
NameToImport :: Prefix ( text, false ) => {
@@ -495,7 +496,7 @@ fn item_for_path_search_assoc(db: &RootDatabase, assoc_item: AssocItem) -> Optio
495
496
}
496
497
497
498
fn trait_applicable_items (
498
- sema : & Semantics < ' _ , RootDatabase > ,
499
+ db : & RootDatabase ,
499
500
current_crate : Crate ,
500
501
scope : & SemanticsScope < ' _ > ,
501
502
trait_candidate : & TraitImportCandidate ,
@@ -505,15 +506,13 @@ fn trait_applicable_items(
505
506
) -> FxIndexSet < LocatedImport > {
506
507
let _p = tracing:: info_span!( "ImportAssets::trait_applicable_items" ) . entered ( ) ;
507
508
508
- let db = sema. db ;
509
-
510
509
let inherent_traits = trait_candidate. receiver_ty . applicable_inherent_traits ( db) ;
511
510
let env_traits = trait_candidate. receiver_ty . env_traits ( db) ;
512
511
let related_traits = inherent_traits. chain ( env_traits) . collect :: < FxHashSet < _ > > ( ) ;
513
512
514
513
let mut required_assoc_items = FxHashSet :: default ( ) ;
515
514
let mut trait_candidates: FxHashSet < _ > = items_locator:: items_with_name (
516
- sema ,
515
+ db ,
517
516
current_crate,
518
517
trait_candidate. assoc_item_name . clone ( ) ,
519
518
AssocSearchMode :: AssocItemsOnly ,
0 commit comments