mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
save-analysis: get tables directly, accomodating them being missing
Fixes an ICE when running with save-analsysis after an error
This commit is contained in:
parent
491b978822
commit
36ad34d343
@ -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)
|
||||
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);
|
||||
self.save_ctxt.tables = self.tcx.item_tables(item_def_id);
|
||||
f(self);
|
||||
self.save_ctxt.tables = old_tables;
|
||||
match self.tcx.tables.borrow().get(&item_def_id) {
|
||||
Some(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) {
|
||||
|
Loading…
Reference in New Issue
Block a user