Skip to content

Rollup of 5 pull requests #41594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
do not access typeck_tables map directly
  • Loading branch information
nikomatsakis committed Apr 27, 2017
commit b67338b9ee5343fc7288fddf6b15d5328c1dc487
14 changes: 5 additions & 9 deletions src/librustc_save_analysis/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,11 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
where F: FnOnce(&mut DumpVisitor<'l, 'tcx, 'll, D>)
{
let item_def_id = self.tcx.hir.local_def_id(item_id);
match self.tcx.maps.typeck_tables_of.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),
}
let tables = self.tcx.typeck_tables_of(item_def_id);
let old_tables = self.save_ctxt.tables;
self.save_ctxt.tables = tables;
f(self);
self.save_ctxt.tables = old_tables;
}

pub fn dump_crate_info(&mut self, name: &str, krate: &ast::Crate) {
Expand Down
12 changes: 4 additions & 8 deletions src/librustc_typeck/check_unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,10 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let item_id = tcx.hir.body_owner(body_id);
let item_def_id = tcx.hir.local_def_id(item_id);

// this will have been written by the main typeck pass
if let Some(tables) = tcx.maps.typeck_tables_of.borrow().get(&item_def_id) {
let imports = &tables.used_trait_imports;
debug!("GatherVisitor: item_def_id={:?} with imports {:#?}", item_def_id, imports);
used_trait_imports.extend(imports);
} else {
debug!("GatherVisitor: item_def_id={:?} with no imports", item_def_id);
}
let tables = tcx.typeck_tables_of(item_def_id);
let imports = &tables.used_trait_imports;
debug!("GatherVisitor: item_def_id={:?} with imports {:#?}", item_def_id, imports);
used_trait_imports.extend(imports);
}

let mut visitor = CheckVisitor { tcx, used_trait_imports };
Expand Down