Consider rustc_deprecated attr when checking for deprecation

This commit is contained in:
Kirill Bulatov 2021-01-19 00:02:59 +02:00
parent bf889bcf3b
commit cc663a7b0c

View File

@ -87,7 +87,8 @@ fn source_range(&self) -> TextRange {
} }
fn is_deprecated(&self, node: impl HasAttrs) -> bool { fn is_deprecated(&self, node: impl HasAttrs) -> bool {
node.attrs(self.db()).by_key("deprecated").exists() let attrs = node.attrs(self.db());
attrs.by_key("deprecated").exists() || attrs.by_key("rustc_deprecated").exists()
} }
fn docs(&self, node: impl HasAttrs) -> Option<Documentation> { fn docs(&self, node: impl HasAttrs) -> Option<Documentation> {
@ -485,7 +486,7 @@ fn sets_deprecated_flag_in_items() {
r#" r#"
#[deprecated] #[deprecated]
fn something_deprecated() {} fn something_deprecated() {}
#[deprecated(since = "1.0.0")] #[rustc_deprecated(since = "1.0.0")]
fn something_else_deprecated() {} fn something_else_deprecated() {}
fn main() { som$0 } fn main() { som$0 }
@ -494,8 +495,8 @@ fn main() { som$0 }
[ [
CompletionItem { CompletionItem {
label: "main()", label: "main()",
source_range: 121..124, source_range: 127..130,
delete: 121..124, delete: 127..130,
insert: "main()$0", insert: "main()$0",
kind: Function, kind: Function,
lookup: "main", lookup: "main",
@ -503,8 +504,8 @@ fn main() { som$0 }
}, },
CompletionItem { CompletionItem {
label: "something_deprecated()", label: "something_deprecated()",
source_range: 121..124, source_range: 127..130,
delete: 121..124, delete: 127..130,
insert: "something_deprecated()$0", insert: "something_deprecated()$0",
kind: Function, kind: Function,
lookup: "something_deprecated", lookup: "something_deprecated",
@ -513,8 +514,8 @@ fn main() { som$0 }
}, },
CompletionItem { CompletionItem {
label: "something_else_deprecated()", label: "something_else_deprecated()",
source_range: 121..124, source_range: 127..130,
delete: 121..124, delete: 127..130,
insert: "something_else_deprecated()$0", insert: "something_else_deprecated()$0",
kind: Function, kind: Function,
lookup: "something_else_deprecated", lookup: "something_else_deprecated",