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.
This commit is contained in:
Nilstrieb 2023-11-21 22:03:00 +01:00
parent 4d563666b1
commit 43d8d51b6d
2 changed files with 8 additions and 4 deletions

View File

@ -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;
}
}

View File

@ -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 {