]> git.proxmox.com Git - rustc.git/blobdiff - src/librustc_mir/dataflow/impls/borrows.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / librustc_mir / dataflow / impls / borrows.rs
index 5e64144df2cd1c371d93d4b1b995017f191f3fd3..5433b7f5f74f7bff208b948e4c5e48fecbd0a3ee 100644 (file)
@@ -1,6 +1,3 @@
-use crate::borrow_check::borrow_set::{BorrowSet, BorrowData};
-use crate::borrow_check::place_ext::PlaceExt;
-
 use rustc::mir::{self, Location, Place, PlaceBase, Body};
 use rustc::ty::{self, TyCtxt};
 use rustc::ty::RegionVid;
@@ -9,10 +6,11 @@ use rustc_index::bit_set::BitSet;
 use rustc_data_structures::fx::FxHashMap;
 use rustc_index::vec::{Idx, IndexVec};
 
+use crate::borrow_check::{
+    ToRegionVid, BorrowSet, BorrowData, RegionInferenceContext, PlaceExt, PlaceConflictBias,
+    places_conflict,
+};
 use crate::dataflow::{BitDenotation, BottomValue, GenKillSet};
-use crate::borrow_check::nll::region_infer::RegionInferenceContext;
-use crate::borrow_check::nll::ToRegionVid;
-use crate::borrow_check::places_conflict;
 
 use std::rc::Rc;
 
@@ -98,7 +96,7 @@ fn precompute_borrows_out_of_scope<'tcx>(
             // Add successor BBs to the work list, if necessary.
             let bb_data = &body[bb];
             assert!(hi == bb_data.statements.len());
-            for &succ_bb in bb_data.terminator.as_ref().unwrap().successors() {
+            for &succ_bb in bb_data.terminator().successors() {
                 visited.entry(succ_bb)
                     .and_modify(|lo| {
                         // `succ_bb` has been seen before. If it wasn't
@@ -153,8 +151,8 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
         }
 
         Borrows {
-            tcx: tcx,
-            body: body,
+            tcx,
+            body,
             param_env,
             borrow_set: borrow_set.clone(),
             borrows_out_of_scope_at_location,
@@ -209,7 +207,9 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
             // local must conflict. This is purely an optimization so we don't have to call
             // `places_conflict` for every borrow.
             if place.projection.is_empty() {
-                trans.kill_all(other_borrows_of_local);
+                if !self.body.local_decls[local].is_ref_to_static() {
+                    trans.kill_all(other_borrows_of_local);
+                }
                 return;
             }
 
@@ -219,13 +219,13 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
             // locations.
             let definitely_conflicting_borrows = other_borrows_of_local
                 .filter(|&&i| {
-                    places_conflict::places_conflict(
+                    places_conflict(
                         self.tcx,
                         self.param_env,
                         self.body,
                         &self.borrow_set.borrows[i].borrowed_place,
                         place,
-                        places_conflict::PlaceConflictBias::NoOverlap)
+                        PlaceConflictBias::NoOverlap)
                 });
 
             trans.kill_all(definitely_conflicting_borrows);