Rollup merge of #39285 - nrc:save-tables, r=@eddyb

save-analysis: get tables directly, accomodating them being missing

Fixes an ICE when running with save-analysis after an error

r? @eddyb
This commit is contained in:
Alex Crichton 2017-01-27 14:41:11 -08:00
commit 666fc45289

View File

@ -111,11 +111,16 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
fn nest_tables<F>(&mut self, item_id: NodeId, f: F) fn nest_tables<F>(&mut self, item_id: NodeId, f: F)
where F: FnOnce(&mut DumpVisitor<'l, 'tcx, 'll, D>) where F: FnOnce(&mut DumpVisitor<'l, 'tcx, 'll, D>)
{ {
let old_tables = self.save_ctxt.tables;
let item_def_id = self.tcx.hir.local_def_id(item_id); let item_def_id = self.tcx.hir.local_def_id(item_id);
self.save_ctxt.tables = self.tcx.item_tables(item_def_id); match self.tcx.tables.borrow().get(&item_def_id) {
f(self); Some(tables) => {
self.save_ctxt.tables = old_tables; let old_tables = self.save_ctxt.tables;
self.save_ctxt.tables = tables;
f(self);
self.save_ctxt.tables = old_tables;
}
None => f(self),
}
} }
pub fn dump_crate_info(&mut self, name: &str, krate: &ast::Crate) { pub fn dump_crate_info(&mut self, name: &str, krate: &ast::Crate) {