diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index f4cbeb5ce9c6..4a28872b1b8d 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -350,16 +350,8 @@ impl<'a> CrateReader<'a> { 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 diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index a7a6ad7abf67..9ba49633f2b3 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -85,7 +85,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> { 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 @@ impl<'tcx> Index<'tcx> { |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(), diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index bfff4615e43b..a1bec7e78a3a 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -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); diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 90ce9662cb0b..e33f5df4d3da 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -136,7 +136,7 @@ fn test_env(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 });