Skip to content

Commit e075823

Browse files
committed
Auto merge of rust-lang#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"`
2 parents 96eab06 + 43d8d51 commit e075823

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

clippy_lints/src/attrs.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ declare_clippy_lint! {
120120
declare_clippy_lint! {
121121
/// ### What it does
122122
/// Checks for `#[deprecated]` annotations with a `since`
123-
/// field that is not a valid semantic version.
123+
/// field that is not a valid semantic version. Also allows "TBD" to signal
124+
/// future deprecation.
124125
///
125126
/// ### Why is this bad?
126127
/// For checking the version of the deprecation, it must be
@@ -479,7 +480,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
479480
&& let MetaItemKind::NameValue(lit) = &mi.kind
480481
&& mi.has_name(sym::since)
481482
{
482-
check_semver(cx, item.span(), lit);
483+
check_deprecated_since(cx, item.span(), lit);
483484
}
484485
}
485486
}
@@ -760,9 +761,9 @@ fn check_attrs(cx: &LateContext<'_>, span: Span, name: Symbol, attrs: &[Attribut
760761
}
761762
}
762763

763-
fn check_semver(cx: &LateContext<'_>, span: Span, lit: &MetaItemLit) {
764+
fn check_deprecated_since(cx: &LateContext<'_>, span: Span, lit: &MetaItemLit) {
764765
if let LitKind::Str(is, _) = lit.kind {
765-
if Version::parse(is.as_str()).is_ok() {
766+
if is.as_str() == "TBD" || Version::parse(is.as_str()).is_ok() {
766767
return;
767768
}
768769
}

tests/ui/attrs.rs

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ pub const ANOTHER_CONST: u8 = 23;
3636
#[deprecated(since = "0.1.1")]
3737
pub const YET_ANOTHER_CONST: u8 = 0;
3838

39+
#[deprecated(since = "TBD")]
40+
pub const GONNA_DEPRECATE_THIS_LATER: u8 = 0;
41+
3942
fn main() {
4043
test_attr_lint();
4144
if false {

0 commit comments

Comments
 (0)