From 1d74ef1d989b3d37f3f08d32e88670ee0f1f7ab6 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 8 Jun 2021 16:50:10 +0200 Subject: Don't complete values in type position --- crates/hir/src/lib.rs | 12 ++++++++++++ crates/hir/src/semantics.rs | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'crates/hir') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index c2b68a853..589641760 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -2496,6 +2496,18 @@ impl ScopeDef { items } + + pub fn is_value_def(&self) -> bool { + matches!( + self, + ScopeDef::ModuleDef(ModuleDef::Function(_)) + | ScopeDef::ModuleDef(ModuleDef::Variant(_)) + | ScopeDef::ModuleDef(ModuleDef::Const(_)) + | ScopeDef::ModuleDef(ModuleDef::Static(_)) + | ScopeDef::GenericParam(GenericParam::ConstParam(_)) + | ScopeDef::Local(_) + ) + } } impl From for ScopeDef { diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index 2d08a7704..827e23e2b 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -35,8 +35,9 @@ pub enum PathResolution { Def(ModuleDef), /// A local binding (only value namespace) Local(Local), - /// A generic parameter + /// A type parameter TypeParam(TypeParam), + /// A const parameter ConstParam(ConstParam), SelfType(Impl), Macro(MacroDef), -- cgit v1.2.3 From ee374ff1ee7ad1af6bc0624f98b2028cef6ed4a8 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 8 Jun 2021 17:31:47 +0200 Subject: fix: don't complete derive macros as fn-like macros --- crates/hir/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'crates/hir') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index c2b68a853..b5209546c 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -1351,6 +1351,13 @@ impl MacroDef { MacroDefKind::ProcMacro(_, base_db::ProcMacroKind::FuncLike, _) => MacroKind::ProcMacro, } } + + pub fn is_fn_like(&self) -> bool { + match self.kind() { + MacroKind::Declarative | MacroKind::BuiltIn | MacroKind::ProcMacro => true, + MacroKind::Attr | MacroKind::Derive => false, + } + } } /// Invariant: `inner.as_assoc_item(db).is_some()` -- cgit v1.2.3