Consider a crate staged if it has stable or unstable in its root

This commit is contained in:
Vadim Petrochenkov 2015-11-26 00:15:46 +03:00
parent 62f5232edb
commit 4b8078424e
4 changed files with 15 additions and 15 deletions

View File

@ -350,18 +350,10 @@ 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" {
if attr.name() == "stable" || attr.name() == "unstable" {
return true
}
}
}
}
}
}
false
}

View File

@ -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(),

View 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);

View 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 });