about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2018-11-08 18:15:05 -0700
committerGitHub <noreply@github.com>2018-11-08 18:15:05 -0700
commit7864780f9edf9c4fa241b0d8136d600e5af5794e (patch)
treed5ebc0a75e457fd9ca1023728acc18f57fd61179
parent792476516f3faeafb873b63e00acebab70ab001d (diff)
parent2d7426bb5a55fa27555de658fca529d8b205ef66 (diff)
downloadrust-7864780f9edf9c4fa241b0d8136d600e5af5794e.tar.gz
rust-7864780f9edf9c4fa241b0d8136d600e5af5794e.zip
Rollup merge of #55753 - ljedrz:borrow_set_insert_clone, r=oli-obk
borrow_set: remove a helper function and a clone it uses

This clone doesn't seem necessary.

r? @oli-obk
-rw-r--r--src/librustc_mir/borrow_check/borrow_set.rs15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/librustc_mir/borrow_check/borrow_set.rs b/src/librustc_mir/borrow_check/borrow_set.rs
index db56ce46274..c432826dca8 100644
--- a/src/librustc_mir/borrow_check/borrow_set.rs
+++ b/src/librustc_mir/borrow_check/borrow_set.rs
@@ -21,7 +21,6 @@ use rustc::util::nodemap::{FxHashMap, FxHashSet};
 use rustc_data_structures::indexed_vec::IndexVec;
 use rustc_data_structures::bit_set::BitSet;
 use std::fmt;
-use std::hash::Hash;
 use std::ops::Index;
 
 crate struct BorrowSet<'tcx> {
@@ -233,21 +232,13 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
 
             self.insert_as_pending_if_two_phase(location, &assigned_place, region, kind, idx);
 
-            insert(&mut self.region_map, &region, idx);
+            self.region_map.entry(region).or_default().insert(idx);
             if let Some(local) = borrowed_place.root_local() {
-                insert(&mut self.local_map, &local, idx);
+                self.local_map.entry(local).or_default().insert(idx);
             }
         }
 
-        return self.super_assign(block, assigned_place, rvalue, location);
-
-        fn insert<'a, K, V>(map: &'a mut FxHashMap<K, FxHashSet<V>>, k: &K, v: V)
-        where
-            K: Clone + Eq + Hash,
-            V: Eq + Hash,
-        {
-            map.entry(k.clone()).or_default().insert(v);
-        }
+        self.super_assign(block, assigned_place, rvalue, location)
     }
 
     fn visit_place(