@@ -123,7 +123,8 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
123123 item_sp : Span , kind : AnnotationKind , visit_children : F )
124124 where F : FnOnce ( & mut Self )
125125 {
126- if self . index . staged_api [ & LOCAL_CRATE ] {
126+ if self . tcx . sess . features . borrow ( ) . staged_api {
127+ // This crate explicitly wants staged API.
127128 debug ! ( "annotate(id = {:?}, attrs = {:?})" , id, attrs) ;
128129 if let Some ( ..) = attr:: find_deprecation ( self . tcx . sess . diagnostic ( ) , attrs, item_sp) {
129130 self . tcx . sess . span_err ( item_sp, "`#[deprecated]` cannot be used in staged api, \
@@ -204,6 +205,15 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
204205 }
205206 }
206207
208+ // Propagate unstability. This can happen even for non-staged-api crates in case
209+ // -Zforce-unstable-if-unmarked is set.
210+ if let Some ( stab) = self . parent_stab {
211+ if stab. level . is_unstable ( ) {
212+ let def_id = self . tcx . hir . local_def_id ( id) ;
213+ self . index . stab_map . insert ( def_id, Some ( stab) ) ;
214+ }
215+ }
216+
207217 if let Some ( depr) = attr:: find_deprecation ( self . tcx . sess . diagnostic ( ) , attrs, item_sp) {
208218 if kind == AnnotationKind :: Prohibited {
209219 self . tcx . sess . span_err ( item_sp, "This deprecation annotation is useless" ) ;
0 commit comments