|
1 | 1 | mod allow_attributes; |
2 | 2 | mod allow_attributes_without_reason; |
3 | 3 | mod blanket_clippy_restriction_lints; |
| 4 | +mod deprecated_attributes_without_note; |
4 | 5 | mod deprecated_attributes_without_since; |
5 | 6 | mod deprecated_cfg_attr; |
6 | 7 | mod deprecated_semver; |
@@ -105,6 +106,30 @@ declare_clippy_lint! { |
105 | 106 | "enabling the complete restriction group" |
106 | 107 | } |
107 | 108 |
|
| 109 | +declare_clippy_lint! { |
| 110 | + /// ### What it does |
| 111 | + /// Checks for attributes that deprecate items without a `note` field. |
| 112 | + /// |
| 113 | + /// ### Why restrict this? |
| 114 | + /// This is typically used to provide an explanation about the deprecation |
| 115 | + /// and preferred alternatives. |
| 116 | + /// |
| 117 | + /// ### Example |
| 118 | + /// ```no_run |
| 119 | + /// #[deprecated] |
| 120 | + /// pub fn foo() { /* ... */ } |
| 121 | + /// ``` |
| 122 | + /// Use instead: |
| 123 | + /// ```no_run |
| 124 | + /// #[deprecated(note = "foo was rarely used. Users should instead use bar")] |
| 125 | + /// pub fn foo() { /* ... */ } |
| 126 | + /// ``` |
| 127 | + #[clippy::version = "1.100.0"] |
| 128 | + pub DEPRECATED_ATTRIBUTES_WITHOUT_NOTE, |
| 129 | + restriction, |
| 130 | + "ensures that all `deprecated` attributes have a `note` field" |
| 131 | +} |
| 132 | + |
108 | 133 | declare_clippy_lint! { |
109 | 134 | /// ### What it does |
110 | 135 | /// Checks for attributes that deprecate items without a `since` field. |
@@ -505,6 +530,7 @@ declare_clippy_lint! { |
505 | 530 | } |
506 | 531 |
|
507 | 532 | impl_lint_pass!(Attributes => [ |
| 533 | + DEPRECATED_ATTRIBUTES_WITHOUT_NOTE, |
508 | 534 | DEPRECATED_ATTRIBUTES_WITHOUT_SINCE, |
509 | 535 | INLINE_ALWAYS, |
510 | 536 | REPR_PACKED_WITHOUT_ABI, |
@@ -637,6 +663,7 @@ impl EarlyLintPass for PostExpansionEarlyAttributes { |
637 | 663 | && !attr.span.in_external_macro(cx.sess().source_map()) |
638 | 664 | && !is_from_proc_macro(cx, attr) |
639 | 665 | { |
| 666 | + deprecated_attributes_without_note::check(cx, attr.meta_item_list().as_deref(), attr); |
640 | 667 | deprecated_attributes_without_since::check(cx, attr.meta_item_list().as_deref(), attr); |
641 | 668 | } |
642 | 669 |
|
|
0 commit comments