@@ -57,36 +57,50 @@ impl<'a> Annotator<'a> {
5757 attrs : & Vec < Attribute > , item_sp : Span , f : F , required : bool ) where
5858 F : FnOnce ( & mut Annotator ) ,
5959 {
60- debug ! ( "annotate(id = {:?}, attrs = {:?})" , id, attrs) ;
61- match attr:: find_stability ( self . sess . diagnostic ( ) , attrs, item_sp) {
62- Some ( stab) => {
63- debug ! ( "annotate: found {:?}" , stab) ;
64- self . index . local . insert ( id, stab. clone ( ) ) ;
65-
66- // Don't inherit #[stable(feature = "rust1", since = "1.0.0")]
67- if stab. level != attr:: Stable {
68- let parent = replace ( & mut self . parent , Some ( stab) ) ;
69- f ( self ) ;
70- self . parent = parent;
71- } else {
60+ if self . index . staged_api {
61+ debug ! ( "annotate(id = {:?}, attrs = {:?})" , id, attrs) ;
62+ match attr:: find_stability ( self . sess . diagnostic ( ) , attrs, item_sp) {
63+ Some ( stab) => {
64+ debug ! ( "annotate: found {:?}" , stab) ;
65+ self . index . local . insert ( id, stab. clone ( ) ) ;
66+
67+ // Don't inherit #[stable(feature = "rust1", since = "1.0.0")]
68+ if stab. level != attr:: Stable {
69+ let parent = replace ( & mut self . parent , Some ( stab) ) ;
70+ f ( self ) ;
71+ self . parent = parent;
72+ } else {
73+ f ( self ) ;
74+ }
75+ }
76+ None => {
77+ debug ! ( "annotate: not found, use_parent = {:?}, parent = {:?}" ,
78+ use_parent, self . parent) ;
79+ if use_parent {
80+ if let Some ( stab) = self . parent . clone ( ) {
81+ self . index . local . insert ( id, stab) ;
82+ } else if self . index . staged_api && required
83+ && self . export_map . contains ( & id)
84+ && !self . sess . opts . test {
85+ self . sess . span_err ( item_sp,
86+ "This node does not have a stability attribute" ) ;
87+ }
88+ }
7289 f ( self ) ;
7390 }
7491 }
75- None => {
76- debug ! ( "annotate: not found, use_parent = {:?}, parent = {:?}" ,
77- use_parent, self . parent) ;
78- if use_parent {
79- if let Some ( stab) = self . parent . clone ( ) {
80- self . index . local . insert ( id, stab) ;
81- } else if self . index . staged_api && required
82- && self . export_map . contains ( & id)
83- && !self . sess . opts . test {
84- self . sess . span_err ( item_sp,
85- "This node does not have a stability attribute" ) ;
86- }
92+ } else {
93+ // Emit warnings for non-staged-api crates. These should be errors.
94+ for attr in attrs {
95+ let tag = attr. name ( ) ;
96+ if tag == "unstable" || tag == "stable" || tag == "deprecated" {
97+ attr:: mark_used ( attr) ;
98+ self . sess . span_warn ( attr. span ( ) ,
99+ "stability attributes are deprecated and \
100+ will soon become errors") ;
87101 }
88- f ( self ) ;
89102 }
103+ f ( self ) ;
90104 }
91105 }
92106}
@@ -157,9 +171,6 @@ impl<'a, 'v> Visitor<'v> for Annotator<'a> {
157171impl Index {
158172 /// Construct the stability index for a crate being compiled.
159173 pub fn build ( & mut self , sess : & Session , krate : & Crate , export_map : & PublicItems ) {
160- if !self . staged_api {
161- return ;
162- }
163174 let mut annotator = Annotator {
164175 sess : sess,
165176 index : self ,
0 commit comments