From 2fe7d17bd9aabe3948b8693c2a3d4841ce9fbd14 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 26 Oct 2023 10:14:29 -0700 Subject: Store version of `deprecated` attribute in structured form --- src/librustdoc/html/render/mod.rs | 13 +++++-------- src/librustdoc/json/conversions.rs | 3 +-- 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 7ab78e73ba7..e852d02b6ac 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -48,7 +48,7 @@ use std::str; use std::string::ToString; use askama::Template; -use rustc_attr::{ConstStability, Deprecation, StabilityLevel, StableSince}; +use rustc_attr::{ConstStability, DeprecatedSince, Deprecation, StabilityLevel, StableSince}; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::def_id::{DefId, DefIdSet}; @@ -617,21 +617,18 @@ fn short_item_info( ) -> Vec { let mut extra_info = vec![]; - if let Some(depr @ Deprecation { note, since, is_since_rustc_version: _, suggestion: _ }) = - item.deprecation(cx.tcx()) - { + if let Some(depr @ Deprecation { note, since, suggestion: _ }) = item.deprecation(cx.tcx()) { // We display deprecation messages for #[deprecated], but only display // the future-deprecation messages for rustc versions. let mut message = if let Some(since) = since { - let since = since.as_str(); if !stability::deprecation_in_effect(&depr) { - if since == "TBD" { + if let DeprecatedSince::Future = since { String::from("Deprecating in a future Rust version") } else { - format!("Deprecating in {}", Escape(since)) + format!("Deprecating in {}", Escape(&since.to_string())) } } else { - format!("Deprecated since {}", Escape(since)) + format!("Deprecated since {}", Escape(&since.to_string())) } } else { String::from("Deprecated") diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 563e0cffddd..ff2e6b1ebc9 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -138,8 +138,7 @@ where } pub(crate) fn from_deprecation(deprecation: rustc_attr::Deprecation) -> Deprecation { - #[rustfmt::skip] - let rustc_attr::Deprecation { since, note, is_since_rustc_version: _, suggestion: _ } = deprecation; + let rustc_attr::Deprecation { since, note, suggestion: _ } = deprecation; Deprecation { since: since.map(|s| s.to_string()), note: note.map(|s| s.to_string()) } } -- cgit 1.4.1-3-g733a5