Skip to content

Commit caa860f

Browse files
committed
fix: also call is_deprecated on ModuleDef
1 parent 0d6ba64 commit caa860f

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

crates/hir/src/attrs.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ pub enum AttrsOwner {
3838
Field(FieldId),
3939
LifetimeParam(LifetimeParamId),
4040
TypeOrConstParam(TypeOrConstParamId),
41-
/// Things that do not have attributes. Used for builtin derives.
41+
/// Things that do not have attributes.
42+
///
43+
/// Used for:
44+
/// - builtin derives
45+
/// - builtin types (as those do not have attributes)
4246
Dummy,
4347
}
4448

crates/hir/src/lib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,23 @@ impl HasCrate for ModuleDef {
556556
}
557557
}
558558

559+
impl HasAttrs for ModuleDef {
560+
fn attr_id(self, db: &dyn HirDatabase) -> attrs::AttrsOwner {
561+
match self {
562+
ModuleDef::Module(it) => it.attr_id(db),
563+
ModuleDef::Function(it) => it.attr_id(db),
564+
ModuleDef::Adt(it) => it.attr_id(db),
565+
ModuleDef::EnumVariant(it) => it.attr_id(db),
566+
ModuleDef::Const(it) => it.attr_id(db),
567+
ModuleDef::Static(it) => it.attr_id(db),
568+
ModuleDef::Trait(it) => it.attr_id(db),
569+
ModuleDef::TypeAlias(it) => it.attr_id(db),
570+
ModuleDef::Macro(it) => it.attr_id(db),
571+
ModuleDef::BuiltinType(_) => attrs::AttrsOwner::Dummy,
572+
}
573+
}
574+
}
575+
559576
impl HasVisibility for ModuleDef {
560577
fn visibility(&self, db: &dyn HirDatabase) -> Visibility {
561578
match *self {

crates/ide-completion/src/render.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ fn scope_def_docs(db: &RootDatabase, resolution: ScopeDef) -> Option<Documentati
576576

577577
fn scope_def_is_deprecated(ctx: &RenderContext<'_>, resolution: ScopeDef) -> bool {
578578
match resolution {
579-
ScopeDef::ModuleDef(it) => ctx.is_deprecated_assoc_item(it),
579+
ScopeDef::ModuleDef(it) => ctx.is_deprecated(it) || ctx.is_deprecated_assoc_item(it),
580580
ScopeDef::GenericParam(it) => ctx.is_deprecated(it),
581581
ScopeDef::AdtSelfType(it) => ctx.is_deprecated(it),
582582
_ => false,
@@ -1577,6 +1577,7 @@ fn main() { som$0 }
15771577
kind: SymbolKind(
15781578
Module,
15791579
),
1580+
deprecated: true,
15801581
},
15811582
]
15821583
"#]],
@@ -1650,6 +1651,7 @@ fn main() { A$0 }
16501651
Struct,
16511652
),
16521653
detail: "A",
1654+
deprecated: true,
16531655
},
16541656
]
16551657
"#]],
@@ -1678,6 +1680,7 @@ fn main() { A$0 }
16781680
Enum,
16791681
),
16801682
detail: "A",
1683+
deprecated: true,
16811684
},
16821685
]
16831686
"#]],
@@ -1792,6 +1795,7 @@ fn main() { A$0 }
17921795
Const,
17931796
),
17941797
detail: "i32",
1798+
deprecated: true,
17951799
},
17961800
]
17971801
"#]],
@@ -1820,6 +1824,7 @@ fn main() { A$0 }
18201824
Static,
18211825
),
18221826
detail: "i32",
1827+
deprecated: true,
18231828
},
18241829
]
18251830
"#]],
@@ -1845,6 +1850,7 @@ impl A$0
18451850
kind: SymbolKind(
18461851
Trait,
18471852
),
1853+
deprecated: true,
18481854
},
18491855
]
18501856
"#]],
@@ -1870,6 +1876,7 @@ fn main() { A$0 }
18701876
kind: SymbolKind(
18711877
TypeAlias,
18721878
),
1879+
deprecated: true,
18731880
},
18741881
]
18751882
"#]],

0 commit comments

Comments
 (0)