@@ -720,7 +720,7 @@ pub fn eval_condition(
720
720
721
721
#[ derive( Copy , Debug , Encodable , Decodable , Clone , HashStable_Generic ) ]
722
722
pub struct Deprecation {
723
- pub since : Option < DeprecatedSince > ,
723
+ pub since : DeprecatedSince ,
724
724
/// The note to issue a reason.
725
725
pub note : Option < Symbol > ,
726
726
/// A text snippet used to completely replace any use of the deprecated item in an expression.
@@ -738,8 +738,10 @@ pub enum DeprecatedSince {
738
738
/// `feature(staged_api)` is off. Deprecation versions outside the standard
739
739
/// library are allowed to be arbitrary strings, for better or worse.
740
740
Symbol ( Symbol ) ,
741
- /// Failed to parse a deprecation version. An error has already been
742
- /// emitted.
741
+ /// Deprecation version is unspecified but optional.
742
+ Unspecified ,
743
+ /// Failed to parse a deprecation version, or the deprecation version is
744
+ /// unspecified and required. An error has already been emitted.
743
745
Err ,
744
746
}
745
747
@@ -749,12 +751,12 @@ impl Deprecation {
749
751
/// version).
750
752
pub fn is_in_effect ( & self ) -> bool {
751
753
match self . since {
752
- Some ( DeprecatedSince :: RustcVersion ( since) ) => since <= RustcVersion :: CURRENT ,
753
- Some ( DeprecatedSince :: Future ) => false ,
754
+ DeprecatedSince :: RustcVersion ( since) => since <= RustcVersion :: CURRENT ,
755
+ DeprecatedSince :: Future => false ,
754
756
// The `since` field doesn't have semantic purpose without `#![staged_api]`.
755
- Some ( DeprecatedSince :: Symbol ( _) ) => true ,
757
+ DeprecatedSince :: Symbol ( _) => true ,
756
758
// Assume deprecation is in effect if "since" field is absent or invalid.
757
- None | Some ( DeprecatedSince :: Err ) => true ,
759
+ DeprecatedSince :: Unspecified | DeprecatedSince :: Err => true ,
758
760
}
759
761
}
760
762
}
@@ -867,20 +869,20 @@ pub fn find_deprecation(
867
869
868
870
let since = if let Some ( since) = since {
869
871
if since. as_str ( ) == "TBD" {
870
- Some ( DeprecatedSince :: Future )
872
+ DeprecatedSince :: Future
871
873
} else if !is_rustc {
872
- Some ( DeprecatedSince :: Symbol ( since) )
874
+ DeprecatedSince :: Symbol ( since)
873
875
} else if let Some ( version) = parse_version ( since) {
874
- Some ( DeprecatedSince :: RustcVersion ( version) )
876
+ DeprecatedSince :: RustcVersion ( version)
875
877
} else {
876
878
sess. emit_err ( session_diagnostics:: InvalidSince { span : attr. span } ) ;
877
- Some ( DeprecatedSince :: Err )
879
+ DeprecatedSince :: Err
878
880
}
881
+ } else if is_rustc {
882
+ sess. emit_err ( session_diagnostics:: MissingSince { span : attr. span } ) ;
883
+ DeprecatedSince :: Err
879
884
} else {
880
- if is_rustc {
881
- sess. emit_err ( session_diagnostics:: MissingSince { span : attr. span } ) ;
882
- }
883
- None
885
+ DeprecatedSince :: Unspecified
884
886
} ;
885
887
886
888
if is_rustc && note. is_none ( ) {
0 commit comments