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]`
|
||||||
Stable {
|
Stable {
|
||||||
/// Rust release which stabilized this feature.
|
/// 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
|
/// Is this item allowed to be referred to on stable, despite being contained in unstable
|
||||||
/// modules?
|
/// modules?
|
||||||
allowed_through_unstable_modules: bool,
|
allowed_through_unstable_modules: bool,
|
||||||
|
@ -149,7 +149,7 @@ pub enum StabilityLevel {
|
||||||
/// Rust release in which a feature is stabilized.
|
/// Rust release in which a feature is stabilized.
|
||||||
#[derive(Encodable, Decodable, PartialEq, Copy, Clone, Debug, Eq, Hash)]
|
#[derive(Encodable, Decodable, PartialEq, Copy, Clone, Debug, Eq, Hash)]
|
||||||
#[derive(HashStable_Generic)]
|
#[derive(HashStable_Generic)]
|
||||||
pub enum Since {
|
pub enum StableSince {
|
||||||
Version(RustcVersion),
|
Version(RustcVersion),
|
||||||
/// Stabilized in the upcoming version, whatever number that is.
|
/// Stabilized in the upcoming version, whatever number that is.
|
||||||
Current,
|
Current,
|
||||||
|
@ -378,16 +378,16 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
|
||||||
|
|
||||||
let since = if let Some(since) = since {
|
let since = if let Some(since) = since {
|
||||||
if since.as_str() == VERSION_PLACEHOLDER {
|
if since.as_str() == VERSION_PLACEHOLDER {
|
||||||
Since::Current
|
StableSince::Current
|
||||||
} else if let Some(version) = parse_version(since) {
|
} else if let Some(version) = parse_version(since) {
|
||||||
Since::Version(version)
|
StableSince::Version(version)
|
||||||
} else {
|
} else {
|
||||||
sess.emit_err(session_diagnostics::InvalidSince { span: attr.span });
|
sess.emit_err(session_diagnostics::InvalidSince { span: attr.span });
|
||||||
Since::Err
|
StableSince::Err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sess.emit_err(session_diagnostics::MissingSince { span: attr.span });
|
sess.emit_err(session_diagnostics::MissingSince { span: attr.span });
|
||||||
Since::Err
|
StableSince::Err
|
||||||
};
|
};
|
||||||
|
|
||||||
match feature {
|
match feature {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
use crate::errors;
|
use crate::errors;
|
||||||
use rustc_attr::{
|
use rustc_attr::{
|
||||||
self as attr, ConstStability, Since, Stability, StabilityLevel, Unstable, UnstableReason,
|
self as attr, ConstStability, Stability, StabilityLevel, StableSince, Unstable, UnstableReason,
|
||||||
VERSION_PLACEHOLDER,
|
VERSION_PLACEHOLDER,
|
||||||
};
|
};
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
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)
|
(&depr.as_ref().and_then(|(d, _)| d.since), &stab.level)
|
||||||
{
|
{
|
||||||
match stab_since {
|
match stab_since {
|
||||||
Since::Current => {
|
StableSince::Current => {
|
||||||
self.tcx.sess.emit_err(errors::CannotStabilizeDeprecated { span, item_sp });
|
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
|
// Explicit version of iter::order::lt to handle parse errors properly
|
||||||
for (dep_v, stab_v) in iter::zip(
|
for (dep_v, stab_v) in iter::zip(
|
||||||
dep_since.as_str().split('.'),
|
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
|
// An error already reported. Assume the unparseable stabilization
|
||||||
// version is older than the deprecation version.
|
// version is older than the deprecation version.
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ use thin_vec::ThinVec;
|
||||||
|
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_ast_pretty::pprust;
|
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_const_eval::const_eval::is_unstable_const_fn;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_hir as hir;
|
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 {
|
match self.stability(tcx)?.level {
|
||||||
StabilityLevel::Stable { since, .. } => Some(since),
|
StabilityLevel::Stable { since, .. } => Some(since),
|
||||||
StabilityLevel::Unstable { .. } => None,
|
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 {
|
match self.const_stability(tcx)?.level {
|
||||||
StabilityLevel::Stable { since, .. } => Some(since),
|
StabilityLevel::Stable { since, .. } => Some(since),
|
||||||
StabilityLevel::Unstable { .. } => None,
|
StabilityLevel::Unstable { .. } => None,
|
||||||
|
|
|
@ -48,7 +48,7 @@ use std::str;
|
||||||
use std::string::ToString;
|
use std::string::ToString;
|
||||||
|
|
||||||
use askama::Template;
|
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::captures::Captures;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_hir::def_id::{DefId, DefIdSet};
|
use rustc_hir::def_id::{DefId, DefIdSet};
|
||||||
|
@ -912,10 +912,10 @@ fn assoc_method(
|
||||||
/// consequence of the above rules.
|
/// consequence of the above rules.
|
||||||
fn render_stability_since_raw_with_extra(
|
fn render_stability_since_raw_with_extra(
|
||||||
w: &mut Buffer,
|
w: &mut Buffer,
|
||||||
ver: Option<Since>,
|
ver: Option<StableSince>,
|
||||||
const_stability: Option<ConstStability>,
|
const_stability: Option<ConstStability>,
|
||||||
containing_ver: Option<Since>,
|
containing_ver: Option<StableSince>,
|
||||||
containing_const_ver: Option<Since>,
|
containing_const_ver: Option<StableSince>,
|
||||||
extra_class: &str,
|
extra_class: &str,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let stable_version = if ver != containing_ver && let Some(ver) = &ver {
|
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()
|
!stability.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn since_to_string(since: &Since) -> Option<String> {
|
fn since_to_string(since: &StableSince) -> Option<String> {
|
||||||
match since {
|
match since {
|
||||||
Since::Version(since) => Some(since.to_string()),
|
StableSince::Version(since) => Some(since.to_string()),
|
||||||
Since::Current => Some(RustcVersion::CURRENT.to_string()),
|
StableSince::Current => Some(RustcVersion::CURRENT.to_string()),
|
||||||
Since::Err => None,
|
StableSince::Err => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn render_stability_since_raw(
|
fn render_stability_since_raw(
|
||||||
w: &mut Buffer,
|
w: &mut Buffer,
|
||||||
ver: Option<Since>,
|
ver: Option<StableSince>,
|
||||||
const_stability: Option<ConstStability>,
|
const_stability: Option<ConstStability>,
|
||||||
containing_ver: Option<Since>,
|
containing_ver: Option<StableSince>,
|
||||||
containing_const_ver: Option<Since>,
|
containing_const_ver: Option<StableSince>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
render_stability_since_raw_with_extra(
|
render_stability_since_raw_with_extra(
|
||||||
w,
|
w,
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
use crate::msrvs::Msrv;
|
use crate::msrvs::Msrv;
|
||||||
use hir::LangItem;
|
use hir::LangItem;
|
||||||
use rustc_attr::Since;
|
use rustc_attr::StableSince;
|
||||||
use rustc_const_eval::transform::check_consts::ConstCx;
|
use rustc_const_eval::transform::check_consts::ConstCx;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::DefId;
|
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.
|
// as a part of an unimplemented MSRV check https://github.com/rust-lang/rust/issues/65262.
|
||||||
|
|
||||||
let const_stab_rust_version = match since {
|
let const_stab_rust_version = match since {
|
||||||
Since::Version(version) => version,
|
StableSince::Version(version) => version,
|
||||||
Since::Current => rustc_session::RustcVersion::CURRENT,
|
StableSince::Current => rustc_session::RustcVersion::CURRENT,
|
||||||
Since::Err => return false,
|
StableSince::Err => return false,
|
||||||
};
|
};
|
||||||
|
|
||||||
msrv.meets(RustcVersion::new(
|
msrv.meets(RustcVersion::new(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue