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
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) {
|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(),
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);
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 });