Skip to content

Commit ddcb183

Browse files
committed
Keep track of #[stable] attribute even if version cannot be parsed
1 parent f2ae7b5 commit ddcb183

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

compiler/rustc_attr/src/builtin.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ pub enum Since {
158158
Version(Version),
159159
/// Stabilized in the upcoming version, whatever number that is.
160160
Current,
161+
/// Failed to parse a stabilization version.
162+
Err,
161163
}
162164

163165
impl StabilityLevel {
@@ -381,22 +383,24 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
381383

382384
let since = if let Some(since) = since {
383385
if since.as_str() == VERSION_PLACEHOLDER {
384-
Ok(Since::Current)
386+
Since::Current
385387
} else if let Some(version) = parse_version(since.as_str(), false) {
386-
Ok(Since::Version(version))
388+
Since::Version(version)
387389
} else {
388-
Err(sess.emit_err(session_diagnostics::InvalidSince { span: attr.span }))
390+
sess.emit_err(session_diagnostics::InvalidSince { span: attr.span });
391+
Since::Err
389392
}
390393
} else {
391-
Err(sess.emit_err(session_diagnostics::MissingSince { span: attr.span }))
394+
sess.emit_err(session_diagnostics::MissingSince { span: attr.span });
395+
Since::Err
392396
};
393397

394-
match (feature, since) {
395-
(Ok(feature), Ok(since)) => {
398+
match feature {
399+
Ok(feature) => {
396400
let level = StabilityLevel::Stable { since, allowed_through_unstable_modules: false };
397401
Some((feature, level))
398402
}
399-
(Err(ErrorGuaranteed { .. }), _) | (_, Err(ErrorGuaranteed { .. })) => None,
403+
Err(ErrorGuaranteed { .. }) => None,
400404
}
401405
}
402406

compiler/rustc_passes/src/stability.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
260260
}
261261
}
262262
}
263+
Since::Err => {
264+
// An error already reported. Assume the unparseable stabilization
265+
// version is older than the deprecation version.
266+
}
263267
}
264268
}
265269

0 commit comments

Comments
 (0)