Skip to content

Commit 0b9e227

Browse files
committed
Move stability pass after privacy pass
1 parent 3b2ed14 commit 0b9e227

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

src/librustc/middle/stability.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub struct Index {
4444
// A private tree-walker for producing an Index.
4545
struct Annotator<'a> {
4646
sess: &'a Session,
47-
index: Index,
47+
index: &'a mut Index,
4848
parent: Option<Stability>
4949
}
5050

@@ -146,7 +146,20 @@ impl<'a, 'v> Visitor<'v> for Annotator<'a> {
146146

147147
impl Index {
148148
/// Construct the stability index for a crate being compiled.
149-
pub fn build(sess: &Session, krate: &Crate) -> Index {
149+
pub fn build(&mut self, sess: &Session, krate: &Crate) {
150+
if !self.staged_api {
151+
return;
152+
}
153+
let mut annotator = Annotator {
154+
sess: sess,
155+
index: self,
156+
parent: None
157+
};
158+
annotator.annotate(ast::CRATE_NODE_ID, true, &krate.attrs, krate.span,
159+
|v| visit::walk_crate(v, krate));
160+
}
161+
162+
pub fn new(krate: &Crate) -> Index {
150163
let mut staged_api = false;
151164
for attr in &krate.attrs {
152165
if attr.name().get() == "staged_api" {
@@ -159,22 +172,11 @@ impl Index {
159172
}
160173
}
161174
}
162-
let index = Index {
175+
Index {
163176
staged_api: staged_api,
164177
local: NodeMap(),
165178
extern_cache: DefIdMap()
166-
};
167-
if !staged_api {
168-
return index;
169179
}
170-
let mut annotator = Annotator {
171-
sess: sess,
172-
index: index,
173-
parent: None
174-
};
175-
annotator.annotate(ast::CRATE_NODE_ID, true, &krate.attrs, krate.span,
176-
|v| visit::walk_crate(v, krate));
177-
annotator.index
178180
}
179181
}
180182

src/librustc_driver/driver.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,6 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
594594
time(time_passes, "loop checking", (), |_|
595595
middle::check_loop::check_crate(&sess, krate));
596596

597-
let stability_index = time(time_passes, "stability index", (), |_|
598-
stability::Index::build(&sess, krate));
599-
600597
time(time_passes, "static item recursion checking", (), |_|
601598
middle::check_static_recursion::check_crate(&sess, krate, &def_map, &ast_map));
602599

@@ -608,7 +605,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
608605
freevars,
609606
region_map,
610607
lang_items,
611-
stability_index);
608+
stability::Index::new(krate));
612609

613610
// passes are timed inside typeck
614611
typeck::check_crate(&ty_cx, trait_map);
@@ -628,6 +625,10 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
628625
time(time_passes, "privacy checking", maps, |(a, b)|
629626
rustc_privacy::check_crate(&ty_cx, &export_map, a, b));
630627

628+
// Do not move this check past lint
629+
time(time_passes, "stability index", (), |_|
630+
ty_cx.stability.borrow_mut().build(&ty_cx.sess, krate));
631+
631632
time(time_passes, "intrinsic checking", (), |_|
632633
middle::intrinsicck::check_crate(&ty_cx));
633634

0 commit comments

Comments
 (0)