@@ -17,7 +17,7 @@ use rustc::hir::map::definitions::DefPathData;
17
17
use rustc:: infer:: InferCtxt ;
18
18
use rustc:: ty:: { self , ParamEnv , TyCtxt } ;
19
19
use rustc:: ty:: maps:: Providers ;
20
- use rustc:: mir:: { AssertMessage , BasicBlock , BorrowKind , Local , Location , Place } ;
20
+ use rustc:: mir:: { AssertMessage , BasicBlock , BorrowKind , Location , Place } ;
21
21
use rustc:: mir:: { Mir , Mutability , Operand , Projection , ProjectionElem , Rvalue } ;
22
22
use rustc:: mir:: { Field , Statement , StatementKind , Terminator , TerminatorKind } ;
23
23
use rustc:: mir:: ClosureRegionRequirements ;
@@ -228,9 +228,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
228
228
hir:: BodyOwnerKind :: Const | hir:: BodyOwnerKind :: Static ( _) => false ,
229
229
hir:: BodyOwnerKind :: Fn => true ,
230
230
} ,
231
- storage_dead_or_drop_error_reported_l : FxHashSet ( ) ,
232
- storage_dead_or_drop_error_reported_s : FxHashSet ( ) ,
233
- read_or_write_error_reported : FxHashSet ( ) ,
231
+ access_place_error_reported : FxHashSet ( ) ,
234
232
reservation_error_reported : FxHashSet ( ) ,
235
233
nonlexical_regioncx : opt_regioncx. clone ( ) ,
236
234
} ;
@@ -295,15 +293,12 @@ pub struct MirBorrowckCtxt<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
295
293
/// I'm not sure this is the right approach - @eddyb could you try and
296
294
/// figure this out?
297
295
locals_are_invalidated_at_exit : bool ,
298
- /// This field keeps track of when storage dead or drop errors are reported
299
- /// in order to stop duplicate error reporting and identify the conditions required
300
- /// for a "temporary value dropped here while still borrowed" error. See #45360.
301
- storage_dead_or_drop_error_reported_l : FxHashSet < Local > ,
302
- /// Same as the above, but for statics (thread-locals)
303
- storage_dead_or_drop_error_reported_s : FxHashSet < DefId > ,
304
- /// This field keeps track of when borrow errors are reported in read or write passes
305
- /// so that an error is not reported in both.
306
- read_or_write_error_reported : FxHashSet < ( Place < ' tcx > , Span ) > ,
296
+ /// This field keeps track of when borrow errors are reported in the access_place function
297
+ /// so that there is no duplicate reporting. This field cannot also be used for the conflicting
298
+ /// borrow errors that is handled by the `reservation_error_reported` field as the inclusion
299
+ /// of the `Span` type (while required to mute some errors) stops the muting of the reservation
300
+ /// errors.
301
+ access_place_error_reported : FxHashSet < ( Place < ' tcx > , Span ) > ,
307
302
/// This field keeps track of when borrow conflict errors are reported
308
303
/// for reservations, so that we don't report seemingly duplicate
309
304
/// errors for corresponding activations
@@ -730,21 +725,17 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
730
725
731
726
if let Activation ( _, borrow_index) = rw {
732
727
if self . reservation_error_reported . contains ( & place_span. 0 ) {
733
- debug ! (
734
- "skipping access_place for activation of invalid reservation \
735
- place: {:?} borrow_index: {:?}",
736
- place_span. 0 ,
737
- borrow_index
738
- ) ;
728
+ debug ! ( "skipping access_place for activation of invalid reservation \
729
+ place: {:?} borrow_index: {:?}", place_span. 0 , borrow_index) ;
739
730
return AccessErrorsReported {
740
731
mutability_error : false ,
741
732
conflict_error : true ,
742
733
} ;
743
734
}
744
735
}
745
736
746
- if self . read_or_write_error_reported . contains ( & ( place_span. 0 . clone ( ) , place_span. 1 ) ) {
747
- debug ! ( "suppressing access_place write for {:?}" , place_span) ;
737
+ if self . access_place_error_reported . contains ( & ( place_span. 0 . clone ( ) , place_span. 1 ) ) {
738
+ debug ! ( "suppressing access_place error for {:?}" , place_span) ;
748
739
return AccessErrorsReported {
749
740
mutability_error : false ,
750
741
conflict_error : true ,
@@ -756,8 +747,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
756
747
let conflict_error =
757
748
self . check_access_for_conflict ( context, place_span, sd, rw, flow_state) ;
758
749
759
- if conflict_error {
760
- self . read_or_write_error_reported . insert ( ( place_span. 0 . clone ( ) , place_span. 1 ) ) ;
750
+ if conflict_error || mutability_error {
751
+ self . access_place_error_reported . insert ( ( place_span. 0 . clone ( ) , place_span. 1 ) ) ;
761
752
}
762
753
763
754
AccessErrorsReported {
@@ -845,15 +836,15 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
845
836
place_span. 0
846
837
) ;
847
838
this. reservation_error_reported . insert ( place_span. 0 . clone ( ) ) ;
848
- }
839
+ } ,
849
840
Activation ( _, activating) => {
850
841
debug ! (
851
842
"observing check_place for activation of \
852
843
borrow_index: {:?}",
853
844
activating
854
845
) ;
855
- }
856
- Read ( ..) | Write ( ..) => { }
846
+ } ,
847
+ Read ( ..) | Write ( ..) => { } ,
857
848
}
858
849
859
850
match kind {
0 commit comments