]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_typeck/check/upvar.rs
Future-proof indexing on maps: remove IndexMut
[rust.git] / src / librustc_typeck / check / upvar.rs
index f452c8488ce1c7eb2fe900db03205d06889460ac..ce4bb4465517b21ef55189e1fc99f2312fae03ee 100644 (file)
@@ -294,7 +294,7 @@ fn adjust_upvar_borrow_kind_for_consume(&self,
 
     /// Indicates that `cmt` is being directly mutated (e.g., assigned
     /// to). If cmt contains any by-ref upvars, this implies that
-    /// those upvars must be borrowed using an `&mut` borow.
+    /// those upvars must be borrowed using an `&mut` borrow.
     fn adjust_upvar_borrow_kind_for_mut(&mut self, cmt: mc::cmt<'tcx>) {
         debug!("adjust_upvar_borrow_kind_for_mut(cmt={})",
                cmt.repr(self.tcx()));
@@ -380,7 +380,7 @@ fn try_adjust_upvar_deref(&self,
                 // borrow_kind of the upvar to make sure it
                 // is inferred to mutable if necessary
                 let mut upvar_capture_map = self.fcx.inh.upvar_capture_map.borrow_mut();
-                let ub = &mut upvar_capture_map[upvar_id];
+                let ub = upvar_capture_map.get_mut(&upvar_id).unwrap();
                 self.adjust_upvar_borrow_kind(upvar_id, ub, borrow_kind);
 
                 // also need to be in an FnMut closure since this is not an ImmBorrow
@@ -556,5 +556,3 @@ fn mutate(&mut self,
         self.adjust_upvar_borrow_kind_for_mut(assignee_cmt);
     }
 }
-
-