Include ErrorGuaranteed in StableSince::Err.

This commit is contained in:
Camille GILLOT
2025-07-16 22:39:04 +00:00
parent 439803dead
commit 83255f57e0
8 changed files with 13 additions and 13 deletions

View File

@@ -24,7 +24,7 @@ use rustc_ast::token::CommentKind;
use rustc_ast::{AttrStyle, IntTy, UintTy}; use rustc_ast::{AttrStyle, IntTy, UintTy};
use rustc_ast_pretty::pp::Printer; use rustc_ast_pretty::pp::Printer;
use rustc_span::hygiene::Transparency; use rustc_span::hygiene::Transparency;
use rustc_span::{Span, Symbol}; use rustc_span::{ErrorGuaranteed, Span, Symbol};
pub use stability::*; pub use stability::*;
use thin_vec::ThinVec; use thin_vec::ThinVec;
pub use version::*; pub use version::*;
@@ -170,7 +170,7 @@ macro_rules! print_tup {
} }
print_tup!(A B C D E F G H); print_tup!(A B C D E F G H);
print_skip!(Span, ()); print_skip!(Span, (), ErrorGuaranteed);
print_disp!(u16, bool, NonZero<u32>); print_disp!(u16, bool, NonZero<u32>);
print_debug!(Symbol, UintTy, IntTy, Align, AttrStyle, CommentKind, Transparency); print_debug!(Symbol, UintTy, IntTy, Align, AttrStyle, CommentKind, Transparency);

View File

@@ -1,7 +1,7 @@
use std::num::NonZero; use std::num::NonZero;
use rustc_macros::{Decodable, Encodable, HashStable_Generic, PrintAttribute}; use rustc_macros::{Decodable, Encodable, HashStable_Generic, PrintAttribute};
use rustc_span::{Symbol, sym}; use rustc_span::{ErrorGuaranteed, Symbol, sym};
use crate::{PrintAttribute, RustcVersion}; use crate::{PrintAttribute, RustcVersion};
@@ -153,7 +153,7 @@ pub enum StableSince {
/// Stabilized in the upcoming version, whatever number that is. /// Stabilized in the upcoming version, whatever number that is.
Current, Current,
/// Failed to parse a stabilization version. /// Failed to parse a stabilization version.
Err, Err(ErrorGuaranteed),
} }
impl StabilityLevel { impl StabilityLevel {

View File

@@ -292,12 +292,12 @@ pub(crate) fn parse_stability<S: Stage>(
} else if let Some(version) = parse_version(since) { } else if let Some(version) = parse_version(since) {
StableSince::Version(version) StableSince::Version(version)
} else { } else {
cx.emit_err(session_diagnostics::InvalidSince { span: cx.attr_span }); let err = cx.emit_err(session_diagnostics::InvalidSince { span: cx.attr_span });
StableSince::Err StableSince::Err(err)
} }
} else { } else {
cx.emit_err(session_diagnostics::MissingSince { span: cx.attr_span }); let err = cx.emit_err(session_diagnostics::MissingSince { span: cx.attr_span });
StableSince::Err StableSince::Err(err)
}; };
match feature { match feature {

View File

@@ -44,7 +44,7 @@ impl<'tcx> LibFeatureCollector<'tcx> {
StabilityLevel::Stable { since, .. } => FeatureStability::AcceptedSince(match since { StabilityLevel::Stable { since, .. } => FeatureStability::AcceptedSince(match since {
StableSince::Version(v) => Symbol::intern(&v.to_string()), StableSince::Version(v) => Symbol::intern(&v.to_string()),
StableSince::Current => sym::env_CFG_RELEASE, StableSince::Current => sym::env_CFG_RELEASE,
StableSince::Err => return None, StableSince::Err(_) => return None,
}), }),
}; };

View File

@@ -421,7 +421,7 @@ impl<'tcx> MissingStabilityAnnotations<'tcx> {
.emit_err(errors::CannotStabilizeDeprecated { span, item_sp }); .emit_err(errors::CannotStabilizeDeprecated { span, item_sp });
} }
} }
StableSince::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.
} }

View File

@@ -1110,7 +1110,7 @@ fn since_to_string(since: &StableSince) -> Option<String> {
match since { match since {
StableSince::Version(since) => Some(since.to_string()), StableSince::Version(since) => Some(since.to_string()),
StableSince::Current => Some(RustcVersion::CURRENT.to_string()), StableSince::Current => Some(RustcVersion::CURRENT.to_string()),
StableSince::Err => None, StableSince::Err(_) => None,
} }
} }

View File

@@ -249,7 +249,7 @@ fn is_stable(cx: &LateContext<'_>, mut def_id: DefId, msrv: Msrv) -> bool {
let stable = match since { let stable = match since {
StableSince::Version(v) => msrv.meets(cx, v), StableSince::Version(v) => msrv.meets(cx, v),
StableSince::Current => msrv.current(cx).is_none(), StableSince::Current => msrv.current(cx).is_none(),
StableSince::Err => false, StableSince::Err(_) => false,
}; };
if !stable { if !stable {

View File

@@ -432,7 +432,7 @@ pub fn is_stable_const_fn(cx: &LateContext<'_>, def_id: DefId, msrv: Msrv) -> bo
let const_stab_rust_version = match since { let const_stab_rust_version = match since {
StableSince::Version(version) => version, StableSince::Version(version) => version,
StableSince::Current => RustcVersion::CURRENT, StableSince::Current => RustcVersion::CURRENT,
StableSince::Err => return false, StableSince::Err(_) => return false,
}; };
msrv.meets(cx, const_stab_rust_version) msrv.meets(cx, const_stab_rust_version)