@@ -720,7 +720,7 @@ pub fn eval_condition(
720720
721721#[ derive( Copy , Debug , Encodable , Decodable , Clone , HashStable_Generic ) ]
722722pub struct Deprecation {
723- pub since : Option < DeprecatedSince > ,
723+ pub since : DeprecatedSince ,
724724 /// The note to issue a reason.
725725 pub note : Option < Symbol > ,
726726 /// A text snippet used to completely replace any use of the deprecated item in an expression.
@@ -738,8 +738,10 @@ pub enum DeprecatedSince {
738738 /// `feature(staged_api)` is off. Deprecation versions outside the standard
739739 /// library are allowed to be arbitrary strings, for better or worse.
740740 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.
743745 Err ,
744746}
745747
@@ -749,12 +751,12 @@ impl Deprecation {
749751 /// version).
750752 pub fn is_in_effect ( & self ) -> bool {
751753 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 ,
754756 // The `since` field doesn't have semantic purpose without `#![staged_api]`.
755- Some ( DeprecatedSince :: Symbol ( _) ) => true ,
757+ DeprecatedSince :: Symbol ( _) => true ,
756758 // Assume deprecation is in effect if "since" field is absent or invalid.
757- None | Some ( DeprecatedSince :: Err ) => true ,
759+ DeprecatedSince :: Unspecified | DeprecatedSince :: Err => true ,
758760 }
759761 }
760762}
@@ -867,20 +869,20 @@ pub fn find_deprecation(
867869
868870 let since = if let Some ( since) = since {
869871 if since. as_str ( ) == "TBD" {
870- Some ( DeprecatedSince :: Future )
872+ DeprecatedSince :: Future
871873 } else if !is_rustc {
872- Some ( DeprecatedSince :: Symbol ( since) )
874+ DeprecatedSince :: Symbol ( since)
873875 } else if let Some ( version) = parse_version ( since) {
874- Some ( DeprecatedSince :: RustcVersion ( version) )
876+ DeprecatedSince :: RustcVersion ( version)
875877 } else {
876878 sess. emit_err ( session_diagnostics:: InvalidSince { span : attr. span } ) ;
877- Some ( DeprecatedSince :: Err )
879+ DeprecatedSince :: Err
878880 }
881+ } else if is_rustc {
882+ sess. emit_err ( session_diagnostics:: MissingSince { span : attr. span } ) ;
883+ DeprecatedSince :: Err
879884 } else {
880- if is_rustc {
881- sess. emit_err ( session_diagnostics:: MissingSince { span : attr. span } ) ;
882- }
883- None
885+ DeprecatedSince :: Unspecified
884886 } ;
885887
886888 if is_rustc && note. is_none ( ) {
0 commit comments