about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-11-22 07:21:48 +0000
committerbors <bors@rust-lang.org>2019-11-22 07:21:48 +0000
commit564f2d30ede19078243bf720f3b0d008aea48f4d (patch)
tree7511f406d207476bf9572236b5ce5a028c204935
parentbd816fd76f4f7a040ca7ac8ca5bc556d761f96fa (diff)
parent965161714bd770d2a86d5864556e3a93d2ad9bc8 (diff)
Auto merge of #66537 - nnethercote:delay-is_local_ever_initialized, r=spastorino
Delay an `is_local_ever_initialized` call.

This commit moves the call after a `return` that almost always runs. It
speeds up the `unicode_normalization` benchmark by about 2%.

r? @spastorino
-rw-r--r--src/librustc_mir/borrow_check/mod.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs
index b8b4a1053e5..f5f1f301e7b 100644
--- a/src/librustc_mir/borrow_check/mod.rs
+++ b/src/librustc_mir/borrow_check/mod.rs
@@ -1883,16 +1883,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
         let error_access;
         let the_place_err;
 
-        // rust-lang/rust#21232, #54986: during period where we reject
-        // partial initialization, do not complain about mutability
-        // errors except for actual mutation (as opposed to an attempt
-        // to do a partial initialization).
-        let previously_initialized = if let PlaceBase::Local(local) = place.base {
-            self.is_local_ever_initialized(local, flow_state).is_some()
-        } else {
-            true
-        };
-
         match kind {
             Reservation(WriteKind::MutableBorrow(borrow_kind @ BorrowKind::Unique))
             | Reservation(WriteKind::MutableBorrow(borrow_kind @ BorrowKind::Mut { .. }))
@@ -1966,8 +1956,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
             }
         }
 
+        // rust-lang/rust#21232, #54986: during period where we reject
+        // partial initialization, do not complain about mutability
+        // errors except for actual mutation (as opposed to an attempt
+        // to do a partial initialization).
+        let previously_initialized = if let PlaceBase::Local(local) = place.base {
+            self.is_local_ever_initialized(local, flow_state).is_some()
+        } else {
+            true
+        };
+
         // at this point, we have set up the error reporting state.
-        return if previously_initialized {
+        if previously_initialized {
             self.report_mutability_error(
                 place,
                 span,
@@ -1978,7 +1978,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
             true
         } else {
             false
-        };
+        }
     }
 
     fn is_local_ever_initialized(