Skip to content

Commit

Permalink
refactor: Move a borrow_mut and unwrap out of a loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Westerlind committed Mar 7, 2020
1 parent b1b558f commit 6095fa1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/librustc_typeck/check/method/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,12 +459,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ProbeScope::TraitsInScope,
)?;
debug!("resolve_ufcs: pick={:?}", pick);
for import_id in pick.import_ids {
let import_def_id = tcx.hir().local_def_id(import_id);
debug!("resolve_ufcs: used_trait_import: {:?}", import_def_id);
Lrc::get_mut(&mut self.tables.borrow_mut().used_trait_imports)
.unwrap()
.insert(import_def_id);
{
let mut tables = self.tables.borrow_mut();
let used_trait_imports = Lrc::get_mut(&mut tables.used_trait_imports).unwrap();
for import_id in pick.import_ids {
let import_def_id = tcx.hir().local_def_id(import_id);
debug!("resolve_ufcs: used_trait_import: {:?}", import_def_id);
used_trait_imports.insert(import_def_id);
}
}

let def_kind = pick.item.def_kind();
Expand Down

0 comments on commit 6095fa1

Please sign in to comment.