From dccf10e98969c31f4a395a3555f781b8dd17b25d Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 30 Oct 2023 16:48:28 -0700 Subject: [PATCH] Descriptive variant name deprecation versions outside the standard library --- compiler/rustc_attr/src/builtin.rs | 6 +++--- compiler/rustc_middle/src/middle/stability.rs | 4 +++- src/librustdoc/html/render/mod.rs | 2 +- src/librustdoc/json/conversions.rs | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index 1334868d05cc9..33e9421eeb4d7 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -737,7 +737,7 @@ pub enum DeprecatedSince { Future, /// `feature(staged_api)` is off. Deprecation versions outside the standard /// library are allowed to be arbitrary strings, for better or worse. - Symbol(Symbol), + NonStandard(Symbol), /// Deprecation version is unspecified but optional. Unspecified, /// Failed to parse a deprecation version, or the deprecation version is @@ -754,7 +754,7 @@ impl Deprecation { DeprecatedSince::RustcVersion(since) => since <= RustcVersion::CURRENT, DeprecatedSince::Future => false, // The `since` field doesn't have semantic purpose without `#![staged_api]`. - DeprecatedSince::Symbol(_) => true, + DeprecatedSince::NonStandard(_) => true, // Assume deprecation is in effect if "since" field is absent or invalid. DeprecatedSince::Unspecified | DeprecatedSince::Err => true, } @@ -871,7 +871,7 @@ pub fn find_deprecation( if since.as_str() == "TBD" { DeprecatedSince::Future } else if !is_rustc { - DeprecatedSince::Symbol(since) + DeprecatedSince::NonStandard(since) } else if let Some(version) = parse_version(since) { DeprecatedSince::RustcVersion(version) } else { diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index c4439896faa07..afa624850ac82 100644 --- a/compiler/rustc_middle/src/middle/stability.rs +++ b/compiler/rustc_middle/src/middle/stability.rs @@ -162,7 +162,9 @@ fn deprecation_message( DeprecatedSince::Future => { format!("use of {kind} `{path}` that will be deprecated in a future Rust version") } - DeprecatedSince::Symbol(_) | DeprecatedSince::Unspecified | DeprecatedSince::Err => { + DeprecatedSince::NonStandard(_) + | DeprecatedSince::Unspecified + | DeprecatedSince::Err => { unreachable!("this deprecation is always in effect; {since:?}") } } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index ea697108ae24f..c52fa01bdc413 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -628,7 +628,7 @@ fn short_item_info( } } DeprecatedSince::Future => String::from("Deprecating in a future Rust version"), - DeprecatedSince::Symbol(since) => { + DeprecatedSince::NonStandard(since) => { format!("Deprecated since {}", Escape(since.as_str())) } DeprecatedSince::Unspecified | DeprecatedSince::Err => String::from("Deprecated"), diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 0b05e304dfc25..285923251f73f 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -143,7 +143,7 @@ pub(crate) fn from_deprecation(deprecation: rustc_attr::Deprecation) -> Deprecat let since = match since { DeprecatedSince::RustcVersion(version) => Some(version.to_string()), DeprecatedSince::Future => Some("TBD".to_owned()), - DeprecatedSince::Symbol(since) => Some(since.to_string()), + DeprecatedSince::NonStandard(since) => Some(since.to_string()), DeprecatedSince::Unspecified | DeprecatedSince::Err => None, }; Deprecation { since, note: note.map(|s| s.to_string()) }