Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transition borrowck to visit all **bodies** and not item-likes #39927

Merged
merged 16 commits into from
Mar 3, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove the borrowck stats
  • Loading branch information
nikomatsakis committed Feb 28, 2017
commit 530b92cfdd415d553050f2f64c5d8ad66f8c4b54
41 changes: 0 additions & 41 deletions src/librustc_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,33 +104,9 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let mut bccx = BorrowckCtxt {
tcx: tcx,
tables: None,
stats: BorrowStats {
loaned_paths_same: 0,
loaned_paths_imm: 0,
stable_paths: 0,
guaranteed_paths: 0
}
};

tcx.visit_all_item_likes_in_krate(DepNode::BorrowCheck, &mut bccx.as_deep_visitor());

if tcx.sess.borrowck_stats() {
println!("--- borrowck stats ---");
println!("paths requiring guarantees: {}",
bccx.stats.guaranteed_paths);
println!("paths requiring loans : {}",
make_stat(&bccx, bccx.stats.loaned_paths_same));
println!("paths requiring imm loans : {}",
make_stat(&bccx, bccx.stats.loaned_paths_imm));
println!("stable paths : {}",
make_stat(&bccx, bccx.stats.stable_paths));
}

fn make_stat(bccx: &BorrowckCtxt, stat: usize) -> String {
let total = bccx.stats.guaranteed_paths as f64;
let perc = if total == 0.0 { 0.0 } else { stat as f64 * 100.0 / total };
format!("{} ({:.0}%)", stat, perc)
}
}

fn borrowck_item<'a, 'tcx>(this: &mut BorrowckCtxt<'a, 'tcx>, item: &'tcx hir::Item) {
Expand Down Expand Up @@ -245,12 +221,6 @@ pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>(
let mut bccx = BorrowckCtxt {
tcx: tcx,
tables: None,
stats: BorrowStats {
loaned_paths_same: 0,
loaned_paths_imm: 0,
stable_paths: 0,
guaranteed_paths: 0
}
};

let dataflow_data = build_borrowck_dataflow_data(&mut bccx, cfg, body);
Expand All @@ -266,17 +236,6 @@ pub struct BorrowckCtxt<'a, 'tcx: 'a> {
// tables for the current thing we are checking; set to
// Some in `borrowck_fn` and cleared later
tables: Option<&'a ty::TypeckTables<'tcx>>,

// Statistics:
stats: BorrowStats
}

#[derive(Clone)]
struct BorrowStats {
loaned_paths_same: usize,
loaned_paths_imm: usize,
stable_paths: usize,
guaranteed_paths: usize
}

///////////////////////////////////////////////////////////////////////////
Expand Down