From 1e5b2da94b238d911796afd88245286324acbf0e Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 26 Oct 2023 10:08:39 -0700 Subject: [PATCH] Rename Since -> StableSince in preparation for a DeprecatedSince --- compiler/rustc_attr/src/builtin.rs | 12 +++++----- compiler/rustc_passes/src/stability.rs | 8 +++---- src/librustdoc/clean/types.rs | 6 ++--- src/librustdoc/html/render/mod.rs | 22 +++++++++---------- .../clippy_utils/src/qualify_min_const_fn.rs | 8 +++---- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index ff23e3da438..592c9ff115b 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -139,7 +139,7 @@ pub enum StabilityLevel { /// `#[stable]` Stable { /// Rust release which stabilized this feature. - since: Since, + since: StableSince, /// Is this item allowed to be referred to on stable, despite being contained in unstable /// modules? allowed_through_unstable_modules: bool, @@ -149,7 +149,7 @@ pub enum StabilityLevel { /// Rust release in which a feature is stabilized. #[derive(Encodable, Decodable, PartialEq, Copy, Clone, Debug, Eq, Hash)] #[derive(HashStable_Generic)] -pub enum Since { +pub enum StableSince { Version(RustcVersion), /// Stabilized in the upcoming version, whatever number that is. Current, @@ -378,16 +378,16 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit let since = if let Some(since) = since { if since.as_str() == VERSION_PLACEHOLDER { - Since::Current + StableSince::Current } else if let Some(version) = parse_version(since) { - Since::Version(version) + StableSince::Version(version) } else { sess.emit_err(session_diagnostics::InvalidSince { span: attr.span }); - Since::Err + StableSince::Err } } else { sess.emit_err(session_diagnostics::MissingSince { span: attr.span }); - Since::Err + StableSince::Err }; match feature { diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 7bfb0742b8b..a3f0f2d6512 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -3,7 +3,7 @@ use crate::errors; use rustc_attr::{ - self as attr, ConstStability, Since, Stability, StabilityLevel, Unstable, UnstableReason, + self as attr, ConstStability, Stability, StabilityLevel, StableSince, Unstable, UnstableReason, VERSION_PLACEHOLDER, }; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; @@ -227,10 +227,10 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { (&depr.as_ref().and_then(|(d, _)| d.since), &stab.level) { match stab_since { - Since::Current => { + StableSince::Current => { self.tcx.sess.emit_err(errors::CannotStabilizeDeprecated { span, item_sp }); } - Since::Version(stab_since) => { + StableSince::Version(stab_since) => { // Explicit version of iter::order::lt to handle parse errors properly for (dep_v, stab_v) in iter::zip( dep_since.as_str().split('.'), @@ -260,7 +260,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { } } } - Since::Err => { + StableSince::Err => { // An error already reported. Assume the unparseable stabilization // version is older than the deprecation version. } diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 455228d04ef..ba55871c75d 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -12,7 +12,7 @@ use thin_vec::ThinVec; use rustc_ast as ast; use rustc_ast_pretty::pprust; -use rustc_attr::{ConstStability, Deprecation, Since, Stability, StabilityLevel}; +use rustc_attr::{ConstStability, Deprecation, Stability, StabilityLevel, StableSince}; use rustc_const_eval::const_eval::is_unstable_const_fn; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; @@ -585,14 +585,14 @@ impl Item { }) } - pub(crate) fn stable_since(&self, tcx: TyCtxt<'_>) -> Option { + pub(crate) fn stable_since(&self, tcx: TyCtxt<'_>) -> Option { match self.stability(tcx)?.level { StabilityLevel::Stable { since, .. } => Some(since), StabilityLevel::Unstable { .. } => None, } } - pub(crate) fn const_stable_since(&self, tcx: TyCtxt<'_>) -> Option { + pub(crate) fn const_stable_since(&self, tcx: TyCtxt<'_>) -> Option { match self.const_stability(tcx)?.level { StabilityLevel::Stable { since, .. } => Some(since), StabilityLevel::Unstable { .. } => None, diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 0b6079b2933..7ab78e73ba7 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, Since, StabilityLevel}; +use rustc_attr::{ConstStability, Deprecation, StabilityLevel, StableSince}; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::def_id::{DefId, DefIdSet}; @@ -912,10 +912,10 @@ fn assoc_method( /// consequence of the above rules. fn render_stability_since_raw_with_extra( w: &mut Buffer, - ver: Option, + ver: Option, const_stability: Option, - containing_ver: Option, - containing_const_ver: Option, + containing_ver: Option, + containing_const_ver: Option, extra_class: &str, ) -> bool { let stable_version = if ver != containing_ver && let Some(ver) = &ver { @@ -977,21 +977,21 @@ fn render_stability_since_raw_with_extra( !stability.is_empty() } -fn since_to_string(since: &Since) -> Option { +fn since_to_string(since: &StableSince) -> Option { match since { - Since::Version(since) => Some(since.to_string()), - Since::Current => Some(RustcVersion::CURRENT.to_string()), - Since::Err => None, + StableSince::Version(since) => Some(since.to_string()), + StableSince::Current => Some(RustcVersion::CURRENT.to_string()), + StableSince::Err => None, } } #[inline] fn render_stability_since_raw( w: &mut Buffer, - ver: Option, + ver: Option, const_stability: Option, - containing_ver: Option, - containing_const_ver: Option, + containing_ver: Option, + containing_const_ver: Option, ) -> bool { render_stability_since_raw_with_extra( w, diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs index 31f7b87de63..ef0e2d3e1b3 100644 --- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs +++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs @@ -5,7 +5,7 @@ use crate::msrvs::Msrv; use hir::LangItem; -use rustc_attr::Since; +use rustc_attr::StableSince; use rustc_const_eval::transform::check_consts::ConstCx; use rustc_hir as hir; use rustc_hir::def_id::DefId; @@ -372,9 +372,9 @@ fn is_const_fn(tcx: TyCtxt<'_>, def_id: DefId, msrv: &Msrv) -> bool { // as a part of an unimplemented MSRV check https://github.com/rust-lang/rust/issues/65262. let const_stab_rust_version = match since { - Since::Version(version) => version, - Since::Current => rustc_session::RustcVersion::CURRENT, - Since::Err => return false, + StableSince::Version(version) => version, + StableSince::Current => rustc_session::RustcVersion::CURRENT, + StableSince::Err => return false, }; msrv.meets(RustcVersion::new(