add completions to show only traits in trait impl statement

This commit is contained in:
dfireBird 2024-02-12 22:56:03 +05:30
parent cf8733353d
commit 0209c28136
No known key found for this signature in database
GPG key ID: 26D522CA5FC2B93D
2 changed files with 28 additions and 0 deletions

View file

@ -184,6 +184,16 @@ pub(crate) fn complete_type_path(
}
}
}
TypeLocation::ImplTrait => {
acc.add_nameref_keywords_with_colon(ctx);
ctx.process_all_names(&mut |name, def, doc_aliases| {
let is_trait = matches!(def, ScopeDef::ModuleDef(hir::ModuleDef::Trait(_)));
if is_trait {
acc.add_path_resolution(ctx, path_ctx, name, def, doc_aliases);
}
});
return;
}
_ => {}
};

View file

@ -989,3 +989,21 @@ fn foo<'a>() { S::<'static, F$0, _, _>; }
"#]],
);
}
#[test]
fn complete_traits_on_impl_trait_block() {
check(
r#"
trait Foo {}
struct Bar;
impl $0 for Bar { }"#,
expect![[r#"
tt Foo
tt Trait
kw crate::
kw self::
"#]],
);
}