Skip to content

Commit e938d76

Browse files
Complete builtin type paths
1 parent 216dc85 commit e938d76

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

crates/completion/src/completions/qualified_path.rs

+33-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
5050
}
5151
}
5252
PathResolution::Def(def @ hir::ModuleDef::Adt(_))
53-
| PathResolution::Def(def @ hir::ModuleDef::TypeAlias(_)) => {
53+
| PathResolution::Def(def @ hir::ModuleDef::TypeAlias(_))
54+
| PathResolution::Def(def @ hir::ModuleDef::BuiltinType(_)) => {
5455
if let hir::ModuleDef::Adt(Adt::Enum(e)) = def {
5556
for variant in e.variants(ctx.db) {
5657
acc.add_enum_variant(ctx, variant, None);
@@ -59,6 +60,13 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
5960
let ty = match def {
6061
hir::ModuleDef::Adt(adt) => adt.ty(ctx.db),
6162
hir::ModuleDef::TypeAlias(a) => a.ty(ctx.db),
63+
hir::ModuleDef::BuiltinType(builtin) => {
64+
let module = match ctx.scope.module() {
65+
Some(it) => it,
66+
None => return,
67+
};
68+
builtin.ty(ctx.db, module)
69+
}
6270
_ => unreachable!(),
6371
};
6472

@@ -780,4 +788,28 @@ impl Foo {
780788
"#]],
781789
);
782790
}
791+
792+
#[test]
793+
fn completes_primitive_assoc_const() {
794+
check(
795+
r#"
796+
//- /lib.rs crate:lib deps:core
797+
fn f() {
798+
u8::$0
799+
}
800+
801+
//- /core.rs crate:core
802+
#[lang = "u8"]
803+
impl u8 {
804+
pub const MAX: Self = 255;
805+
806+
pub fn func(self) {}
807+
}
808+
"#,
809+
expect![[r#"
810+
ct MAX pub const MAX: Self = 255;
811+
me func(…) -> ()
812+
"#]],
813+
);
814+
}
783815
}

0 commit comments

Comments
 (0)