Skip to content

Commit 5a25e1d

Browse files
committed
Make sure crates not opting in to staged_api don't use staged_api
1 parent 3504343 commit 5a25e1d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/librustc/middle/stability.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -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");

src/libtest/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#![feature(libc)]
3838
#![feature(set_stdio)]
3939
#![feature(panic_unwind)]
40+
#![feature(staged_api)]
4041

4142
extern crate getopts;
4243
extern crate term;

0 commit comments

Comments
 (0)