Skip to content

Instantly share code, notes, and snippets.

@Nashenas88
Created May 23, 2017 00:18
Show Gist options
  • Save Nashenas88/7ae2cc6b9a0baa4e361a80d39a238ab7 to your computer and use it in GitHub Desktop.
Save Nashenas88/7ae2cc6b9a0baa4e361a80d39a238ab7 to your computer and use it in GitHub Desktop.
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, save_analysis: bool) -> Option<HashMap<DefId, AnalysisResult<'a, 'tcx>>> {
if save_analysis {
info!("Performing save_analysis borrowck");
let mut map = HashMap::new();
for body_owner_def_id in tcx.body_owners() {
info!("Borrow checking {:?}", body_owner_def_id);
let result = borrowck(tcx, body_owner_def_id, save_analysis).unwrap();
map.insert(body_owner_def_id, result);
}
Some(map)
} else {
info!("Performing non-save_analysis borrowck");
for body_owner_def_id in tcx.body_owners() {
info!("Borrow checking {:?}", body_owner_def_id);
tcx.borrowck(body_owner_def_id);
}
None
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment