]> git.lizzy.rs Git - rust.git/commitdiff
mir/borrowck: deduplicate assignments and returns
authorljedrz <ljedrz@gmail.com>
Tue, 16 Oct 2018 13:13:11 +0000 (15:13 +0200)
committerljedrz <ljedrz@gmail.com>
Wed, 17 Oct 2018 12:40:47 +0000 (14:40 +0200)
src/librustc_mir/borrow_check/mod.rs

index 59bb534881e33a64c2356d86db5a62653ed83da7..ce0cc20f6de34bf0a8023559e53930b69b1ac8c4 100644 (file)
@@ -1009,13 +1009,12 @@ fn check_access_for_conflict(
                         return Control::Continue;
                     }
 
+                    error_reported = true;
                     match kind {
                         ReadKind::Copy  => {
-                            error_reported = true;
                             this.report_use_while_mutably_borrowed(context, place_span, borrow)
                         }
                         ReadKind::Borrow(bk) => {
-                            error_reported = true;
                             this.report_conflicting_borrow(context, place_span, bk, &borrow)
                         }
                     }
@@ -1045,13 +1044,12 @@ fn check_access_for_conflict(
                         Read(..) | Write(..) => {}
                     }
 
+                    error_reported = true;
                     match kind {
                         WriteKind::MutableBorrow(bk) => {
-                            error_reported = true;
                             this.report_conflicting_borrow(context, place_span, bk, &borrow)
                         }
                         WriteKind::StorageDeadOrDrop => {
-                            error_reported = true;
                             this.report_borrowed_value_does_not_live_long_enough(
                                 context,
                                 borrow,
@@ -1059,11 +1057,9 @@ fn check_access_for_conflict(
                                 Some(kind))
                         }
                         WriteKind::Mutate => {
-                            error_reported = true;
                             this.report_illegal_mutation_of_borrowed(context, place_span, borrow)
                         }
                         WriteKind::Move => {
-                            error_reported = true;
                             this.report_move_out_while_borrowed(context, place_span, &borrow)
                         }
                     }