Rename Since -> StableSince in preparation for a DeprecatedSince
This commit is contained in:
parent
1dfb6b162b
commit
1e5b2da94b
5 changed files with 28 additions and 28 deletions
|
@ -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 {
|
||||
|
|
|
@ -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.
|
||||
}
|
||||
|
|
|
@ -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<Since> {
|
||||
pub(crate) fn stable_since(&self, tcx: TyCtxt<'_>) -> Option<StableSince> {
|
||||
match self.stability(tcx)?.level {
|
||||
StabilityLevel::Stable { since, .. } => Some(since),
|
||||
StabilityLevel::Unstable { .. } => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn const_stable_since(&self, tcx: TyCtxt<'_>) -> Option<Since> {
|
||||
pub(crate) fn const_stable_since(&self, tcx: TyCtxt<'_>) -> Option<StableSince> {
|
||||
match self.const_stability(tcx)?.level {
|
||||
StabilityLevel::Stable { since, .. } => Some(since),
|
||||
StabilityLevel::Unstable { .. } => None,
|
||||
|
|
|
@ -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<Since>,
|
||||
ver: Option<StableSince>,
|
||||
const_stability: Option<ConstStability>,
|
||||
containing_ver: Option<Since>,
|
||||
containing_const_ver: Option<Since>,
|
||||
containing_ver: Option<StableSince>,
|
||||
containing_const_ver: Option<StableSince>,
|
||||
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<String> {
|
||||
fn since_to_string(since: &StableSince) -> Option<String> {
|
||||
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<Since>,
|
||||
ver: Option<StableSince>,
|
||||
const_stability: Option<ConstStability>,
|
||||
containing_ver: Option<Since>,
|
||||
containing_const_ver: Option<Since>,
|
||||
containing_ver: Option<StableSince>,
|
||||
containing_const_ver: Option<StableSince>,
|
||||
) -> bool {
|
||||
render_stability_since_raw_with_extra(
|
||||
w,
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Reference in a new issue