Unnamed repository; edit this file 'description' to name the repository.
fix: also call `is_deprecated` on `ModuleDef`
| -rw-r--r-- | crates/hir/src/attrs.rs | 6 | ||||
| -rw-r--r-- | crates/hir/src/lib.rs | 17 | ||||
| -rw-r--r-- | crates/ide-completion/src/render.rs | 9 |
3 files changed, 30 insertions, 2 deletions
diff --git a/crates/hir/src/attrs.rs b/crates/hir/src/attrs.rs index bec91032b9..223103b6e5 100644 --- a/crates/hir/src/attrs.rs +++ b/crates/hir/src/attrs.rs @@ -38,7 +38,11 @@ pub enum AttrsOwner { Field(FieldId), LifetimeParam(LifetimeParamId), TypeOrConstParam(TypeOrConstParamId), - /// Things that do not have attributes. Used for builtin derives. + /// Things that do not have attributes. + /// + /// Used for: + /// - builtin derives + /// - builtin types (as those do not have attributes) Dummy, } diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 27516ed80b..1ae6643294 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -556,6 +556,23 @@ impl HasCrate for ModuleDef { } } +impl HasAttrs for ModuleDef { + fn attr_id(self, db: &dyn HirDatabase) -> attrs::AttrsOwner { + match self { + ModuleDef::Module(it) => it.attr_id(db), + ModuleDef::Function(it) => it.attr_id(db), + ModuleDef::Adt(it) => it.attr_id(db), + ModuleDef::EnumVariant(it) => it.attr_id(db), + ModuleDef::Const(it) => it.attr_id(db), + ModuleDef::Static(it) => it.attr_id(db), + ModuleDef::Trait(it) => it.attr_id(db), + ModuleDef::TypeAlias(it) => it.attr_id(db), + ModuleDef::Macro(it) => it.attr_id(db), + ModuleDef::BuiltinType(_) => attrs::AttrsOwner::Dummy, + } + } +} + impl HasVisibility for ModuleDef { fn visibility(&self, db: &dyn HirDatabase) -> Visibility { match *self { diff --git a/crates/ide-completion/src/render.rs b/crates/ide-completion/src/render.rs index a855898e76..5a34782235 100644 --- a/crates/ide-completion/src/render.rs +++ b/crates/ide-completion/src/render.rs @@ -576,7 +576,7 @@ fn scope_def_docs(db: &RootDatabase, resolution: ScopeDef) -> Option<Documentati fn scope_def_is_deprecated(ctx: &RenderContext<'_>, resolution: ScopeDef) -> bool { match resolution { - ScopeDef::ModuleDef(it) => ctx.is_deprecated_assoc_item(it), + ScopeDef::ModuleDef(it) => ctx.is_deprecated(it) || ctx.is_deprecated_assoc_item(it), ScopeDef::GenericParam(it) => ctx.is_deprecated(it), ScopeDef::AdtSelfType(it) => ctx.is_deprecated(it), _ => false, @@ -1577,6 +1577,7 @@ fn main() { som$0 } kind: SymbolKind( Module, ), + deprecated: true, }, ] "#]], @@ -1650,6 +1651,7 @@ fn main() { A$0 } Struct, ), detail: "A", + deprecated: true, }, ] "#]], @@ -1678,6 +1680,7 @@ fn main() { A$0 } Enum, ), detail: "A", + deprecated: true, }, ] "#]], @@ -1792,6 +1795,7 @@ fn main() { A$0 } Const, ), detail: "i32", + deprecated: true, }, ] "#]], @@ -1820,6 +1824,7 @@ fn main() { A$0 } Static, ), detail: "i32", + deprecated: true, }, ] "#]], @@ -1845,6 +1850,7 @@ impl A$0 kind: SymbolKind( Trait, ), + deprecated: true, }, ] "#]], @@ -1870,6 +1876,7 @@ fn main() { A$0 } kind: SymbolKind( TypeAlias, ), + deprecated: true, }, ] "#]], |