]> git.lizzy.rs Git - rust.git/commitdiff
save-analysis: get tables directly, accomodating them being missing
authorNick Cameron <ncameron@mozilla.com>
Wed, 25 Jan 2017 01:40:47 +0000 (14:40 +1300)
committerNick Cameron <ncameron@mozilla.com>
Thu, 26 Jan 2017 18:21:06 +0000 (07:21 +1300)
Fixes an ICE when running with save-analsysis after an error

src/librustc_save_analysis/dump_visitor.rs

index 74521fe465bcd45360924e94547972cb80725239..f128167bbf621b50e074a27a3d34bd2227ddaf70 100644 (file)
@@ -111,11 +111,16 @@ fn nest_scope<F>(&mut self, scope_id: NodeId, f: F)
     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) {