about summary refs log tree commit diff
path: root/compiler/rustc_attr/src
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2023-10-23 23:06:52 -0700
committerDavid Tolnay <dtolnay@gmail.com>2023-10-24 15:50:23 -0700
commitddcb1833ff0d0c4d6bf26163f64e4ad1617e65ff (patch)
tree0848bc9492713c0a888a38f12c4a9ef30c142abb /compiler/rustc_attr/src
parentf2ae7b55ae3283d37fa7cca6b4740981af51b845 (diff)
Keep track of #[stable] attribute even if version cannot be parsed
Diffstat (limited to 'compiler/rustc_attr/src')
-rw-r--r--compiler/rustc_attr/src/builtin.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs
index d01eae383a4..7081e285d68 100644
--- a/compiler/rustc_attr/src/builtin.rs
+++ b/compiler/rustc_attr/src/builtin.rs
@@ -158,6 +158,8 @@ pub enum Since {
     Version(Version),
     /// Stabilized in the upcoming version, whatever number that is.
     Current,
+    /// Failed to parse a stabilization version.
+    Err,
 }
 
 impl StabilityLevel {
@@ -381,22 +383,24 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
 
     let since = if let Some(since) = since {
         if since.as_str() == VERSION_PLACEHOLDER {
-            Ok(Since::Current)
+            Since::Current
         } else if let Some(version) = parse_version(since.as_str(), false) {
-            Ok(Since::Version(version))
+            Since::Version(version)
         } else {
-            Err(sess.emit_err(session_diagnostics::InvalidSince { span: attr.span }))
+            sess.emit_err(session_diagnostics::InvalidSince { span: attr.span });
+            Since::Err
         }
     } 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) {
-        (Ok(feature), Ok(since)) => {
+    match feature {
+        Ok(feature) => {
             let level = StabilityLevel::Stable { since, allowed_through_unstable_modules: false };
             Some((feature, level))
         }
-        (Err(ErrorGuaranteed { .. }), _) | (_, Err(ErrorGuaranteed { .. })) => None,
+        Err(ErrorGuaranteed { .. }) => None,
     }
 }