Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 2156815

Browse files
author
Jonas Schievink
committed
Make completion work too
1 parent 7e45915 commit 2156815

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

crates/ide-completion/src/completions/type.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,9 @@ pub(crate) fn complete_type_path(acc: &mut Completions, ctx: &CompletionContext)
168168
if let Some(hir::PathResolution::Def(hir::ModuleDef::Trait(trait_))) =
169169
ctx.sema.resolve_path(&path_seg.parent_path())
170170
{
171-
trait_.items(ctx.sema.db).into_iter().for_each(|it| {
171+
trait_.items_with_supertraits(ctx.sema.db).into_iter().for_each(|it| {
172172
if let hir::AssocItem::TypeAlias(alias) = it {
173+
cov_mark::hit!(complete_assoc_type_in_generics_list);
173174
acc.add_type_alias_with_eq(ctx, alias)
174175
}
175176
});

crates/ide-completion/src/tests/type_pos.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,13 @@ fn foo<'lt, T, const C: usize>() {
336336

337337
#[test]
338338
fn completes_types_and_const_in_arg_list() {
339+
cov_mark::check!(complete_assoc_type_in_generics_list);
339340
check(
340341
r#"
341-
trait Trait2 {
342+
trait Trait1 {
343+
type Super;
344+
}
345+
trait Trait2: Trait1 {
342346
type Foo;
343347
}
344348
@@ -348,14 +352,16 @@ fn foo<'lt, T: Trait2<$0>, const CONST_PARAM: usize>(_: T) {}
348352
ct CONST
349353
cp CONST_PARAM
350354
en Enum
351-
ma makro!(…) macro_rules! makro
355+
ma makro!(…) macro_rules! makro
352356
md module
353357
st Record
354358
st Tuple
355359
st Unit
356360
tt Trait
361+
tt Trait1
357362
tt Trait2
358-
ta Foo = (as Trait2) type Foo
363+
ta Foo = (as Trait2) type Foo
364+
ta Super = (as Trait1) type Super
359365
tp T
360366
un Union
361367
bt u32

0 commit comments

Comments
 (0)