Move stability pass after privacy pass

This commit is contained in:
Manish Goregaokar 2015-02-03 21:16:08 +05:30
parent 3b2ed14906
commit 0b9e227a16
2 changed files with 21 additions and 18 deletions

View File

@ -44,7 +44,7 @@ pub struct Index {
// A private tree-walker for producing an Index.
struct Annotator<'a> {
sess: &'a Session,
index: Index,
index: &'a mut Index,
parent: Option<Stability>
}
@ -146,7 +146,20 @@ impl<'a, 'v> Visitor<'v> for Annotator<'a> {
impl Index {
/// Construct the stability index for a crate being compiled.
pub fn build(sess: &Session, krate: &Crate) -> Index {
pub fn build(&mut self, sess: &Session, krate: &Crate) {
if !self.staged_api {
return;
}
let mut annotator = Annotator {
sess: sess,
index: self,
parent: None
};
annotator.annotate(ast::CRATE_NODE_ID, true, &krate.attrs, krate.span,
|v| visit::walk_crate(v, krate));
}
pub fn new(krate: &Crate) -> Index {
let mut staged_api = false;
for attr in &krate.attrs {
if attr.name().get() == "staged_api" {
@ -159,22 +172,11 @@ impl Index {
}
}
}
let index = Index {
Index {
staged_api: staged_api,
local: NodeMap(),
extern_cache: DefIdMap()
};
if !staged_api {
return index;
}
let mut annotator = Annotator {
sess: sess,
index: index,
parent: None
};
annotator.annotate(ast::CRATE_NODE_ID, true, &krate.attrs, krate.span,
|v| visit::walk_crate(v, krate));
annotator.index
}
}

View File

@ -594,9 +594,6 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
time(time_passes, "loop checking", (), |_|
middle::check_loop::check_crate(&sess, krate));
let stability_index = time(time_passes, "stability index", (), |_|
stability::Index::build(&sess, krate));
time(time_passes, "static item recursion checking", (), |_|
middle::check_static_recursion::check_crate(&sess, krate, &def_map, &ast_map));
@ -608,7 +605,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
freevars,
region_map,
lang_items,
stability_index);
stability::Index::new(krate));
// passes are timed inside typeck
typeck::check_crate(&ty_cx, trait_map);
@ -628,6 +625,10 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
time(time_passes, "privacy checking", maps, |(a, b)|
rustc_privacy::check_crate(&ty_cx, &export_map, a, b));
// Do not move this check past lint
time(time_passes, "stability index", (), |_|
ty_cx.stability.borrow_mut().build(&ty_cx.sess, krate));
time(time_passes, "intrinsic checking", (), |_|
middle::intrinsicck::check_crate(&ty_cx));