Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide_completion/src/completions/qualified_path.rs')
| -rw-r--r-- | crates/ide_completion/src/completions/qualified_path.rs | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/crates/ide_completion/src/completions/qualified_path.rs b/crates/ide_completion/src/completions/qualified_path.rs index 3930adbf0e..534d27d983 100644 --- a/crates/ide_completion/src/completions/qualified_path.rs +++ b/crates/ide_completion/src/completions/qualified_path.rs @@ -57,7 +57,7 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon match ctx.completion_location { Some(ImmediateLocation::ItemList | ImmediateLocation::Trait | ImmediateLocation::Impl) => { if let hir::PathResolution::Def(hir::ModuleDef::Module(module)) = resolution { - for (name, def) in module.scope(ctx.db, ctx.module) { + for (name, def) in module.scope(ctx.db, Some(ctx.module)) { if let Some(def) = module_or_fn_macro(ctx.db, def) { acc.add_resolution(ctx, name, def); } @@ -89,7 +89,7 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon match resolution { hir::PathResolution::Def(hir::ModuleDef::Module(module)) => { - let module_scope = module.scope(ctx.db, ctx.module); + let module_scope = module.scope(ctx.db, Some(ctx.module)); for (name, def) in module_scope { let add_resolution = match def { // Don't suggest attribute macros and derives. @@ -141,29 +141,26 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon // XXX: For parity with Rust bug #22519, this does not complete Ty::AssocType. // (where AssocType is defined on a trait, not an inherent impl) - let krate = ctx.krate; - if let Some(krate) = krate { - let traits_in_scope = traits_in_scope(ctx); - ty.iterate_path_candidates( - ctx.db, - &ctx.scope, - &traits_in_scope, - ctx.module, - None, - |item| { - add_assoc_item(acc, ctx, item); - None::<()> - }, - ); - - // Iterate assoc types separately - ty.iterate_assoc_items(ctx.db, krate, |item| { - if let hir::AssocItem::TypeAlias(ty) = item { - acc.add_type_alias(ctx, ty) - } + let traits_in_scope = traits_in_scope(ctx); + ty.iterate_path_candidates( + ctx.db, + &ctx.scope, + &traits_in_scope, + Some(ctx.module), + None, + |item| { + add_assoc_item(acc, ctx, item); None::<()> - }); - } + }, + ); + + // Iterate assoc types separately + ty.iterate_assoc_items(ctx.db, ctx.krate, |item| { + if let hir::AssocItem::TypeAlias(ty) = item { + acc.add_type_alias(ctx, ty) + } + None::<()> + }); } hir::PathResolution::Def(hir::ModuleDef::Trait(t)) => { // Handles `Trait::assoc` as well as `<Ty as Trait>::assoc`. @@ -187,7 +184,7 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon ctx.db, &ctx.scope, &traits_in_scope, - ctx.module, + Some(ctx.module), None, |item| { // We might iterate candidates of a trait multiple times here, so deduplicate |