]> git.lizzy.rs Git - rust.git/commitdiff
Make sure crates not opting in to staged_api don't use staged_api
authorRalf Jung <post@ralfj.de>
Sun, 20 Aug 2017 14:49:03 +0000 (16:49 +0200)
committerRalf Jung <post@ralfj.de>
Sun, 20 Aug 2017 14:57:36 +0000 (16:57 +0200)
src/librustc/middle/stability.rs
src/libtest/lib.rs

index 5158c7e94af4c3025c1626cae5e91909fff1d599..d2ed29a3a0ff636c3d778b9ed9c26e81e62c85f6 100644 (file)
@@ -123,7 +123,8 @@ fn annotate<F>(&mut self, id: NodeId, attrs: &[Attribute],
                    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, \
@@ -204,6 +205,15 @@ fn annotate<F>(&mut self, id: NodeId, attrs: &[Attribute],
                 }
             }
 
+            // 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");
index 5451ec24aa8fca5021e7990eb01fe2a51010290b..5e34688f8cb8f0e7ffc6997cee5aa353bf728843 100644 (file)
@@ -37,6 +37,7 @@
 #![feature(libc)]
 #![feature(set_stdio)]
 #![feature(panic_unwind)]
+#![feature(staged_api)]
 
 extern crate getopts;
 extern crate term;