Skip to content

Commit 4b80784

Browse files
committed
Consider a crate staged if it has stable or unstable in its root
1 parent 62f5232 commit 4b80784

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/librustc/metadata/creader.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -350,16 +350,8 @@ impl<'a> CrateReader<'a> {
350350
fn is_staged_api(&self, data: &[u8]) -> bool {
351351
let attrs = decoder::get_crate_attributes(data);
352352
for attr in &attrs {
353-
if attr.name() == "feature" {
354-
if let Some(metas) = attr.meta_item_list() {
355-
for meta in metas {
356-
if let ast::MetaWord(ref name) = meta.node {
357-
if &name[..] == "staged_api" {
358-
return true
359-
}
360-
}
361-
}
362-
}
353+
if attr.name() == "stable" || attr.name() == "unstable" {
354+
return true
363355
}
364356
}
365357
false

src/librustc/middle/stability.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
8585
item_sp: Span, kind: AnnotationKind, visit_children: F)
8686
where F: FnOnce(&mut Annotator)
8787
{
88-
if self.index.staged_api[&LOCAL_CRATE] {
88+
if self.index.staged_api[&LOCAL_CRATE] && self.tcx.sess.features.borrow().staged_api {
8989
debug!("annotate(id = {:?}, attrs = {:?})", id, attrs);
9090
if let Some(mut stab) = attr::find_stability(self.tcx.sess.diagnostic(),
9191
attrs, item_sp) {
@@ -279,9 +279,17 @@ impl<'tcx> Index<'tcx> {
279279
|v| intravisit::walk_crate(v, krate));
280280
}
281281

282-
pub fn new(sess: &Session) -> Index<'tcx> {
282+
pub fn new(krate: &Crate) -> Index<'tcx> {
283+
let mut is_staged_api = false;
284+
for attr in &krate.attrs {
285+
if attr.name() == "stable" || attr.name() == "unstable" {
286+
is_staged_api = true;
287+
break
288+
}
289+
}
290+
283291
let mut staged_api = FnvHashMap();
284-
staged_api.insert(LOCAL_CRATE, sess.features.borrow().staged_api);
292+
staged_api.insert(LOCAL_CRATE, is_staged_api);
285293
Index {
286294
staged_api: staged_api,
287295
map: DefIdMap(),

src/librustc_driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
738738
freevars,
739739
region_map,
740740
lang_items,
741-
stability::Index::new(sess),
741+
stability::Index::new(krate),
742742
|tcx| {
743743
// passes are timed inside typeck
744744
typeck::check_crate(tcx, trait_map);

src/librustc_driver/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ fn test_env<F>(source_string: &str,
136136
freevars,
137137
region_map,
138138
lang_items,
139-
stability::Index::new(&sess),
139+
stability::Index::new(krate),
140140
|tcx| {
141141
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, false);
142142
body(Env { infcx: &infcx });

0 commit comments

Comments
 (0)