diff options
| author | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2023-11-21 22:03:00 +0100 |
|---|---|---|
| committer | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2023-11-21 22:03:00 +0100 |
| commit | 43d8d51b6d3e7ed95a425a8bcca6aae0467fff9f (patch) | |
| tree | 39f3dd4ec1669328bfcdb0433d38e672dc092236 | |
| parent | 4d563666b1e36ced2e588a92ab26288ad7daf48e (diff) | |
| download | rust-43d8d51b6d3e7ed95a425a8bcca6aae0467fff9f.tar.gz rust-43d8d51b6d3e7ed95a425a8bcca6aae0467fff9f.zip | |
Allow `#[deprecated(since = "TBD")]`
"TBD" is allowed by rustdoc, saying that it will be deprecated in a future version. rustc will also not actually warn on it.
| -rw-r--r-- | clippy_lints/src/attrs.rs | 9 | ||||
| -rw-r--r-- | tests/ui/attrs.rs | 3 |
2 files changed, 8 insertions, 4 deletions
diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 0a4a0ab9f07..694bc8755a6 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -120,7 +120,8 @@ declare_clippy_lint! { declare_clippy_lint! { /// ### What it does /// Checks for `#[deprecated]` annotations with a `since` - /// field that is not a valid semantic version. + /// field that is not a valid semantic version. Also allows "TBD" to signal + /// future deprecation. /// /// ### Why is this bad? /// For checking the version of the deprecation, it must be @@ -479,7 +480,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes { && let MetaItemKind::NameValue(lit) = &mi.kind && mi.has_name(sym::since) { - check_semver(cx, item.span(), lit); + check_deprecated_since(cx, item.span(), lit); } } } @@ -760,9 +761,9 @@ fn check_attrs(cx: &LateContext<'_>, span: Span, name: Symbol, attrs: &[Attribut } } -fn check_semver(cx: &LateContext<'_>, span: Span, lit: &MetaItemLit) { +fn check_deprecated_since(cx: &LateContext<'_>, span: Span, lit: &MetaItemLit) { if let LitKind::Str(is, _) = lit.kind { - if Version::parse(is.as_str()).is_ok() { + if is.as_str() == "TBD" || Version::parse(is.as_str()).is_ok() { return; } } diff --git a/tests/ui/attrs.rs b/tests/ui/attrs.rs index 05ee48d17b1..da96eabede1 100644 --- a/tests/ui/attrs.rs +++ b/tests/ui/attrs.rs @@ -36,6 +36,9 @@ pub const ANOTHER_CONST: u8 = 23; #[deprecated(since = "0.1.1")] pub const YET_ANOTHER_CONST: u8 = 0; +#[deprecated(since = "TBD")] +pub const GONNA_DEPRECATE_THIS_LATER: u8 = 0; + fn main() { test_attr_lint(); if false { |
