@@ -124,7 +124,6 @@ pub fn find_unwind_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> Op
124
124
///
125
125
/// - `#[stable]`
126
126
/// - `#[unstable]`
127
- /// - `#[rustc_deprecated]`
128
127
#[ derive( RustcEncodable , RustcDecodable , Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
129
128
#[ derive( HashStable_Generic ) ]
130
129
pub struct Stability {
@@ -213,7 +212,6 @@ where
213
212
214
213
' outer: for attr in attrs_iter {
215
214
if ![
216
- sym:: rustc_deprecated,
217
215
sym:: rustc_const_unstable,
218
216
sym:: rustc_const_stable,
219
217
sym:: unstable,
@@ -299,35 +297,6 @@ where
299
297
300
298
let meta_name = meta. name_or_empty ( ) ;
301
299
match meta_name {
302
- sym:: rustc_deprecated => {
303
- if rustc_depr. is_some ( ) {
304
- struct_span_err ! (
305
- diagnostic,
306
- item_sp,
307
- E0540 ,
308
- "multiple rustc_deprecated attributes"
309
- )
310
- . emit ( ) ;
311
- continue ' outer;
312
- }
313
-
314
- get_meta ! ( since, reason, suggestion) ;
315
-
316
- match ( since, reason) {
317
- ( Some ( since) , Some ( reason) ) => {
318
- rustc_depr = Some ( RustcDeprecation { since, reason, suggestion } )
319
- }
320
- ( None , _) => {
321
- handle_errors ( sess, attr. span , AttrError :: MissingSince ) ;
322
- continue ;
323
- }
324
- _ => {
325
- struct_span_err ! ( diagnostic, attr. span, E0543 , "missing 'reason'" )
326
- . emit ( ) ;
327
- continue ;
328
- }
329
- }
330
- }
331
300
sym:: rustc_const_unstable | sym:: unstable => {
332
301
if meta_name == sym:: unstable && stab. is_some ( ) {
333
302
handle_errors ( sess, attr. span , AttrError :: MultipleStabilityLevels ) ;
@@ -714,7 +683,16 @@ pub fn eval_condition(
714
683
#[ derive( RustcEncodable , RustcDecodable , Clone , HashStable_Generic ) ]
715
684
pub struct Deprecation {
716
685
pub since : Option < Symbol > ,
686
+ /// The note to issue a reason.
717
687
pub note : Option < Symbol > ,
688
+ /// A text snippet used to completely replace any use of the deprecated item in an expression.
689
+ ///
690
+ /// This is currently unstable.
691
+ pub suggestion : Option < Symbol > ,
692
+
693
+ /// Whether to treat the since attribute as being a Rust version identifier
694
+ /// (rather than an opaque string).
695
+ pub is_since_rustc_version : bool ,
718
696
}
719
697
720
698
/// Finds the deprecation attribute. `None` if none exists.
@@ -738,7 +716,7 @@ where
738
716
let diagnostic = & sess. span_diagnostic ;
739
717
740
718
' outer: for attr in attrs_iter {
741
- if !attr. check_name ( sym:: deprecated) {
719
+ if !( attr. check_name ( sym:: deprecated) || attr . check_name ( sym :: rustc_deprecated ) ) {
742
720
continue ;
743
721
}
744
722
@@ -751,11 +729,12 @@ where
751
729
Some ( meta) => meta,
752
730
None => continue ,
753
731
} ;
754
- depr = match & meta. kind {
755
- MetaItemKind :: Word => Some ( Deprecation { since : None , note : None } ) ,
756
- MetaItemKind :: NameValue ( ..) => {
757
- meta. value_str ( ) . map ( |note| Deprecation { since : None , note : Some ( note) } )
758
- }
732
+ let mut since = None ;
733
+ let mut note = None ;
734
+ let mut suggestion = None ;
735
+ match & meta. kind {
736
+ MetaItemKind :: Word => { }
737
+ MetaItemKind :: NameValue ( ..) => note = meta. value_str ( ) ,
759
738
MetaItemKind :: List ( list) => {
760
739
let get = |meta : & MetaItem , item : & mut Option < Symbol > | {
761
740
if item. is_some ( ) {
@@ -789,8 +768,6 @@ where
789
768
}
790
769
} ;
791
770
792
- let mut since = None ;
793
- let mut note = None ;
794
771
for meta in list {
795
772
match meta {
796
773
NestedMetaItem :: MetaItem ( mi) => match mi. name_or_empty ( ) {
@@ -799,18 +776,32 @@ where
799
776
continue ' outer;
800
777
}
801
778
}
802
- sym:: note => {
779
+ sym:: note if attr. check_name ( sym:: deprecated) => {
780
+ if !get ( mi, & mut note) {
781
+ continue ' outer;
782
+ }
783
+ }
784
+ sym:: reason if attr. check_name ( sym:: rustc_deprecated) => {
803
785
if !get ( mi, & mut note) {
804
786
continue ' outer;
805
787
}
806
788
}
789
+ sym:: suggestion if attr. check_name ( sym:: rustc_deprecated) => {
790
+ if !get ( mi, & mut suggestion) {
791
+ continue ' outer;
792
+ }
793
+ }
807
794
_ => {
808
795
handle_errors (
809
796
sess,
810
797
meta. span ( ) ,
811
798
AttrError :: UnknownMetaItem (
812
799
pprust:: path_to_string ( & mi. path ) ,
813
- & [ "since" , "note" ] ,
800
+ if attr. check_name ( sym:: deprecated) {
801
+ & [ "since" , "note" ]
802
+ } else {
803
+ & [ "since" , "reason" , "suggestion" ]
804
+ } ,
814
805
) ,
815
806
) ;
816
807
continue ' outer;
@@ -829,10 +820,29 @@ where
829
820
}
830
821
}
831
822
}
823
+ }
824
+ }
825
+
826
+ if suggestion. is_some ( ) && attr. check_name ( sym:: deprecated) {
827
+ unreachable ! ( "only allowed on rustc_deprecated" )
828
+ }
832
829
833
- Some ( Deprecation { since, note } )
830
+ if attr. check_name ( sym:: rustc_deprecated) {
831
+ if since. is_none ( ) {
832
+ handle_errors ( sess, attr. span , AttrError :: MissingSince ) ;
833
+ continue ;
834
834
}
835
- } ;
835
+
836
+ if note. is_none ( ) {
837
+ struct_span_err ! ( diagnostic, attr. span, E0543 , "missing 'reason'" ) . emit ( ) ;
838
+ continue ;
839
+ }
840
+ }
841
+
842
+ mark_used ( & attr) ;
843
+
844
+ let is_since_rustc_version = attr. check_name ( sym:: rustc_deprecated) ;
845
+ depr = Some ( Deprecation { since, note, suggestion, is_since_rustc_version } ) ;
836
846
}
837
847
838
848
depr
0 commit comments