Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/render.rs')
-rw-r--r--crates/ide-completion/src/render.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/ide-completion/src/render.rs b/crates/ide-completion/src/render.rs
index 608dec1285..433d49820d 100644
--- a/crates/ide-completion/src/render.rs
+++ b/crates/ide-completion/src/render.rs
@@ -120,6 +120,15 @@ impl<'a> RenderContext<'a> {
})
}
+ /// Whether an enum variant should be rendered as deprecated.
+ ///
+ /// A variant inherits deprecation from its parent enum, matching rustc's
+ /// behavior where `#[deprecated]` on an enum applies to its variants.
+ fn is_variant_deprecated(&self, variant: hir::EnumVariant) -> bool {
+ let db = self.db();
+ variant.attrs(db).is_deprecated() || variant.parent_enum(db).attrs(db).is_deprecated()
+ }
+
// FIXME: remove this
fn docs(&self, def: impl HasDocs) -> Option<Documentation<'a>> {
def.docs(self.db())
@@ -583,6 +592,7 @@ fn scope_def_docs(db: &RootDatabase, resolution: ScopeDef) -> Option<Documentati
fn scope_def_is_deprecated(ctx: &RenderContext<'_>, resolution: ScopeDef) -> bool {
let db = ctx.db();
match resolution {
+ ScopeDef::ModuleDef(hir::ModuleDef::EnumVariant(it)) => ctx.is_variant_deprecated(it),
ScopeDef::ModuleDef(it) => ctx.is_deprecated(it, it.as_assoc_item(db)),
ScopeDef::GenericParam(it) => {
ctx.is_deprecated(it, None /* generic params can't be assoc items */)