about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-11-24 14:46:50 +0000
committerbors <bors@rust-lang.org>2023-11-24 14:46:50 +0000
commite075823e2c3fe08f096a34f58b7cd41e88e6b7f9 (patch)
treece9cfcbd32b163b18de36235603783fe9d9852ec
parent96eab0655fc5afee4d93db05bed7126160c35254 (diff)
parent43d8d51b6d3e7ed95a425a8bcca6aae0467fff9f (diff)
downloadrust-e075823e2c3fe08f096a34f58b7cd41e88e6b7f9.tar.gz
rust-e075823e2c3fe08f096a34f58b7cd41e88e6b7f9.zip
Auto merge of #11850 - Nilstrieb:tbd, r=dswij
[`deprecated_semver`]: 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.
I found this while checking the rust-lang/rust with clippy.

changelog: [`deprecated_semver`]: allow using `since = "TBD"`
-rw-r--r--clippy_lints/src/attrs.rs9
-rw-r--r--tests/ui/attrs.rs3
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 {