From 5127d24a3e863a0ce99bffd6bacfce396ae0813b Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Tue, 24 Nov 2015 01:51:58 +0300 Subject: [PATCH] Remove `#[staged_api]` --- src/doc/reference.md | 4 ---- src/librustc/metadata/creader.rs | 15 +++++++++++---- src/librustc/middle/stability.rs | 14 ++------------ src/librustc_driver/driver.rs | 2 +- src/librustc_driver/test.rs | 2 +- src/libsyntax/feature_gate.rs | 5 +++-- src/test/compile-fail/staged_api.rs | 13 ------------- 7 files changed, 18 insertions(+), 37 deletions(-) delete mode 100644 src/test/compile-fail/staged_api.rs diff --git a/src/doc/reference.md b/src/doc/reference.md index 949ffb9a5f0..80194ea27bf 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -2325,10 +2325,6 @@ The currently implemented features of the reference compiler are: * `simd_ffi` - Allows use of SIMD vectors in signatures for foreign functions. The SIMD interface is subject to change. -* `staged_api` - Allows usage of stability markers and `#![staged_api]` in a - crate. Stability markers are also attributes: `#[stable]`, - `#[unstable]`, and `#[rustc_deprecated]` are the three levels. - * `start` - Allows use of the `#[start]` attribute, which changes the entry point into a Rust program. This capability, especially the signature for the annotated function, is subject to change. diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 6ce5d1117a6..f4cbeb5ce9c 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -350,12 +350,19 @@ 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()[..] == "staged_api" { - match attr.node.value.node { ast::MetaWord(_) => return true, _ => (/*pass*/) } + 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 + } + } + } + } } } - - return false; + false } fn resolve_crate(&mut self, diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index b5ba219f495..a7a6ad7abf6 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -279,19 +279,9 @@ impl<'tcx> Index<'tcx> { |v| intravisit::walk_crate(v, krate)); } - pub fn new(krate: &Crate) -> Index { - let mut is_staged_api = false; - for attr in &krate.attrs { - if attr.name() == "staged_api" { - if let ast::MetaWord(_) = attr.node.value.node { - attr::mark_used(attr); - is_staged_api = true; - break - } - } - } + pub fn new(sess: &Session) -> Index<'tcx> { let mut staged_api = FnvHashMap(); - staged_api.insert(LOCAL_CRATE, is_staged_api); + staged_api.insert(LOCAL_CRATE, sess.features.borrow().staged_api); Index { staged_api: staged_api, map: DefIdMap(), diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index a1bec7e78a3..bfff4615e43 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(krate), + stability::Index::new(sess), |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 e33f5df4d3d..90ce9662cb0 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(krate), + stability::Index::new(&sess), |tcx| { let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, false); body(Env { infcx: &infcx }); diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 1663bdca51f..b450331d440 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -277,8 +277,6 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGat // Not used any more, but we can't feature gate it ("no_stack_check", Normal, Ungated), - ("staged_api", CrateLevel, Gated("staged_api", - "staged_api is for use by rustc only")), ("plugin", CrateLevel, Gated("plugin", "compiler plugins are experimental \ and possibly buggy")), @@ -501,6 +499,7 @@ pub struct Features { pub cfg_target_vendor: bool, pub augmented_assignments: bool, pub braced_empty_structs: bool, + pub staged_api: bool, } impl Features { @@ -532,6 +531,7 @@ impl Features { cfg_target_vendor: false, augmented_assignments: false, braced_empty_structs: false, + staged_api: false, } } } @@ -1104,6 +1104,7 @@ fn check_crate_inner(cm: &CodeMap, span_handler: &SpanHandler, cfg_target_vendor: cx.has_feature("cfg_target_vendor"), augmented_assignments: cx.has_feature("augmented_assignments"), braced_empty_structs: cx.has_feature("braced_empty_structs"), + staged_api: cx.has_feature("staged_api"), } } diff --git a/src/test/compile-fail/staged_api.rs b/src/test/compile-fail/staged_api.rs deleted file mode 100644 index 53d687b5cfe..00000000000 --- a/src/test/compile-fail/staged_api.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![staged_api] //~ ERROR staged_api is for use by rustc only - -fn main() { }