Keep track of #[stable] attribute even if version cannot be parsed
This commit is contained in:
parent
f2ae7b55ae
commit
ddcb1833ff
@ -158,6 +158,8 @@ pub enum Since {
|
|||||||
Version(Version),
|
Version(Version),
|
||||||
/// 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.
|
||||||
|
Err,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StabilityLevel {
|
impl StabilityLevel {
|
||||||
@ -381,22 +383,24 @@ 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 {
|
||||||
Ok(Since::Current)
|
Since::Current
|
||||||
} else if let Some(version) = parse_version(since.as_str(), false) {
|
} else if let Some(version) = parse_version(since.as_str(), false) {
|
||||||
Ok(Since::Version(version))
|
Since::Version(version)
|
||||||
} else {
|
} else {
|
||||||
Err(sess.emit_err(session_diagnostics::InvalidSince { span: attr.span }))
|
sess.emit_err(session_diagnostics::InvalidSince { span: attr.span });
|
||||||
|
Since::Err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Err(sess.emit_err(session_diagnostics::MissingSince { span: attr.span }))
|
sess.emit_err(session_diagnostics::MissingSince { span: attr.span });
|
||||||
|
Since::Err
|
||||||
};
|
};
|
||||||
|
|
||||||
match (feature, since) {
|
match feature {
|
||||||
(Ok(feature), Ok(since)) => {
|
Ok(feature) => {
|
||||||
let level = StabilityLevel::Stable { since, allowed_through_unstable_modules: false };
|
let level = StabilityLevel::Stable { since, allowed_through_unstable_modules: false };
|
||||||
Some((feature, level))
|
Some((feature, level))
|
||||||
}
|
}
|
||||||
(Err(ErrorGuaranteed { .. }), _) | (_, Err(ErrorGuaranteed { .. })) => None,
|
Err(ErrorGuaranteed { .. }) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,6 +260,10 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Since::Err => {
|
||||||
|
// An error already reported. Assume the unparseable stabilization
|
||||||
|
// version is older than the deprecation version.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user