Skip to content

Commit d26a7a4

Browse files
committed
do not access typeck_tables map directly
1 parent b11da34 commit d26a7a4

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

src/librustc_save_analysis/dump_visitor.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,11 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
114114
where F: FnOnce(&mut DumpVisitor<'l, 'tcx, 'll, D>)
115115
{
116116
let item_def_id = self.tcx.hir.local_def_id(item_id);
117-
match self.tcx.maps.typeck_tables_of.borrow().get(&item_def_id) {
118-
Some(tables) => {
119-
let old_tables = self.save_ctxt.tables;
120-
self.save_ctxt.tables = tables;
121-
f(self);
122-
self.save_ctxt.tables = old_tables;
123-
}
124-
None => f(self),
125-
}
117+
let tables = self.tcx.typeck_tables_of(item_def_id);
118+
let old_tables = self.save_ctxt.tables;
119+
self.save_ctxt.tables = tables;
120+
f(self);
121+
self.save_ctxt.tables = old_tables;
126122
}
127123

128124
pub fn dump_crate_info(&mut self, name: &str, krate: &ast::Crate) {

src/librustc_typeck/check_unused.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,10 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
6666
let item_id = tcx.hir.body_owner(body_id);
6767
let item_def_id = tcx.hir.local_def_id(item_id);
6868

69-
// this will have been written by the main typeck pass
70-
if let Some(tables) = tcx.maps.typeck_tables_of.borrow().get(&item_def_id) {
71-
let imports = &tables.used_trait_imports;
72-
debug!("GatherVisitor: item_def_id={:?} with imports {:#?}", item_def_id, imports);
73-
used_trait_imports.extend(imports);
74-
} else {
75-
debug!("GatherVisitor: item_def_id={:?} with no imports", item_def_id);
76-
}
69+
let tables = tcx.typeck_tables_of(item_def_id);
70+
let imports = &tables.used_trait_imports;
71+
debug!("GatherVisitor: item_def_id={:?} with imports {:#?}", item_def_id, imports);
72+
used_trait_imports.extend(imports);
7773
}
7874

7975
let mut visitor = CheckVisitor { tcx, used_trait_imports };

0 commit comments

Comments
 (0)