diff options
Diffstat (limited to 'crates/completion')
-rw-r--r-- | crates/completion/src/completions/qualified_path.rs | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/crates/completion/src/completions/qualified_path.rs b/crates/completion/src/completions/qualified_path.rs index bbeaab496..2afa6979e 100644 --- a/crates/completion/src/completions/qualified_path.rs +++ b/crates/completion/src/completions/qualified_path.rs | |||
@@ -50,7 +50,8 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon | |||
50 | } | 50 | } |
51 | } | 51 | } |
52 | PathResolution::Def(def @ hir::ModuleDef::Adt(_)) | 52 | 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(_)) => { | ||
54 | if let hir::ModuleDef::Adt(Adt::Enum(e)) = def { | 55 | if let hir::ModuleDef::Adt(Adt::Enum(e)) = def { |
55 | for variant in e.variants(ctx.db) { | 56 | for variant in e.variants(ctx.db) { |
56 | acc.add_enum_variant(ctx, variant, None); | 57 | acc.add_enum_variant(ctx, variant, None); |
@@ -59,6 +60,13 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon | |||
59 | let ty = match def { | 60 | let ty = match def { |
60 | hir::ModuleDef::Adt(adt) => adt.ty(ctx.db), | 61 | hir::ModuleDef::Adt(adt) => adt.ty(ctx.db), |
61 | hir::ModuleDef::TypeAlias(a) => a.ty(ctx.db), | 62 | 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 | } | ||
62 | _ => unreachable!(), | 70 | _ => unreachable!(), |
63 | }; | 71 | }; |
64 | 72 | ||
@@ -780,4 +788,28 @@ impl Foo { | |||
780 | "#]], | 788 | "#]], |
781 | ); | 789 | ); |
782 | } | 790 | } |
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 | } | ||
783 | } | 815 | } |