]> git.lizzy.rs Git - rust.git/commitdiff
Consider a crate staged if it has `stable` or `unstable` in its root
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Wed, 25 Nov 2015 21:15:46 +0000 (00:15 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Wed, 25 Nov 2015 21:15:46 +0000 (00:15 +0300)
src/librustc/metadata/creader.rs
src/librustc/middle/stability.rs
src/librustc_driver/driver.rs
src/librustc_driver/test.rs

index f4cbeb5ce9c616a9ba9848c0547010c6ab3c585a..4a28872b1b8d659099f81e997f3f75de5d16d494 100644 (file)
@@ -350,16 +350,8 @@ fn register_crate(&mut self,
     fn is_staged_api(&self, data: &[u8]) -> bool {
         let attrs = decoder::get_crate_attributes(data);
         for attr in &attrs {
-            if attr.name() == "feature" {
-                if let Some(metas) = attr.meta_item_list() {
-                    for meta in metas {
-                        if let ast::MetaWord(ref name) = meta.node {
-                            if &name[..] == "staged_api" {
-                                return true
-                            }
-                        }
-                    }
-                }
+            if attr.name() == "stable" || attr.name() == "unstable" {
+                return true
             }
         }
         false
index a7a6ad7abf67115ec092abfd71dd193e4a00580f..9ba49633f2b3ba701a6f07f47dc94fc0555d006a 100644 (file)
@@ -85,7 +85,7 @@ fn annotate<F>(&mut self, id: NodeId, attrs: &Vec<Attribute>,
                    item_sp: Span, kind: AnnotationKind, visit_children: F)
         where F: FnOnce(&mut Annotator)
     {
-        if self.index.staged_api[&LOCAL_CRATE] {
+        if self.index.staged_api[&LOCAL_CRATE] && self.tcx.sess.features.borrow().staged_api {
             debug!("annotate(id = {:?}, attrs = {:?})", id, attrs);
             if let Some(mut stab) = attr::find_stability(self.tcx.sess.diagnostic(),
                                                          attrs, item_sp) {
@@ -279,9 +279,17 @@ pub fn build(&mut self, tcx: &ty::ctxt<'tcx>, krate: &Crate, access_levels: &Acc
                            |v| intravisit::walk_crate(v, krate));
     }
 
-    pub fn new(sess: &Session) -> Index<'tcx> {
+    pub fn new(krate: &Crate) -> Index<'tcx> {
+        let mut is_staged_api = false;
+        for attr in &krate.attrs {
+            if attr.name() == "stable" || attr.name() == "unstable" {
+                is_staged_api = true;
+                break
+            }
+        }
+
         let mut staged_api = FnvHashMap();
-        staged_api.insert(LOCAL_CRATE, sess.features.borrow().staged_api);
+        staged_api.insert(LOCAL_CRATE, is_staged_api);
         Index {
             staged_api: staged_api,
             map: DefIdMap(),
index bfff4615e43b4f69b2d8bc980a708da6e4ca4bd3..a1bec7e78a3adb5622ad63d55d9711337172ef9a 100644 (file)
@@ -738,7 +738,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
                                freevars,
                                region_map,
                                lang_items,
-                               stability::Index::new(sess),
+                               stability::Index::new(krate),
                                |tcx| {
                                    // passes are timed inside typeck
                                    typeck::check_crate(tcx, trait_map);
index 90ce9662cb0b262d967f850a1289be19fbb80409..e33f5df4d3da42905db9baf522aa389ca1d8bf09 100644 (file)
@@ -136,7 +136,7 @@ fn test_env<F>(source_string: &str,
                                freevars,
                                region_map,
                                lang_items,
-                               stability::Index::new(&sess),
+                               stability::Index::new(krate),
                                |tcx| {
                                    let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, false);
                                    body(Env { infcx: &infcx });