Skip to content

Commit

Permalink
Make sure crates not opting in to staged_api don't use staged_api
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Aug 20, 2017
1 parent 3504343 commit 5a25e1d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/librustc/middle/stability.rs
Expand Up @@ -123,7 +123,8 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
item_sp: Span, kind: AnnotationKind, visit_children: F)
where F: FnOnce(&mut Self)
{
if self.index.staged_api[&LOCAL_CRATE] {
if self.tcx.sess.features.borrow().staged_api {
// This crate explicitly wants staged API.
debug!("annotate(id = {:?}, attrs = {:?})", id, attrs);
if let Some(..) = attr::find_deprecation(self.tcx.sess.diagnostic(), attrs, item_sp) {
self.tcx.sess.span_err(item_sp, "`#[deprecated]` cannot be used in staged api, \
Expand Down Expand Up @@ -204,6 +205,15 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
}
}

// Propagate unstability. This can happen even for non-staged-api crates in case
// -Zforce-unstable-if-unmarked is set.
if let Some(stab) = self.parent_stab {
if stab.level.is_unstable() {
let def_id = self.tcx.hir.local_def_id(id);
self.index.stab_map.insert(def_id, Some(stab));
}
}

if let Some(depr) = attr::find_deprecation(self.tcx.sess.diagnostic(), attrs, item_sp) {
if kind == AnnotationKind::Prohibited {
self.tcx.sess.span_err(item_sp, "This deprecation annotation is useless");
Expand Down
1 change: 1 addition & 0 deletions src/libtest/lib.rs
Expand Up @@ -37,6 +37,7 @@
#![feature(libc)]
#![feature(set_stdio)]
#![feature(panic_unwind)]
#![feature(staged_api)]

extern crate getopts;
extern crate term;
Expand Down

0 comments on commit 5a25e1d

Please sign in to comment.