@@ -17,7 +17,7 @@ use rustc::hir::map::definitions::DefPathData;
1717use rustc:: infer:: InferCtxt ;
1818use rustc:: ty:: { self , ParamEnv , TyCtxt } ;
1919use rustc:: ty:: maps:: Providers ;
20- use rustc:: mir:: { AssertMessage , BasicBlock , BorrowKind , Local , Location , Place } ;
20+ use rustc:: mir:: { AssertMessage , BasicBlock , BorrowKind , Location , Place } ;
2121use rustc:: mir:: { Mir , Mutability , Operand , Projection , ProjectionElem , Rvalue } ;
2222use rustc:: mir:: { Field , Statement , StatementKind , Terminator , TerminatorKind } ;
2323use rustc:: mir:: ClosureRegionRequirements ;
@@ -228,9 +228,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
228228 hir:: BodyOwnerKind :: Const | hir:: BodyOwnerKind :: Static ( _) => false ,
229229 hir:: BodyOwnerKind :: Fn => true ,
230230 } ,
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 ( ) ,
234232 reservation_error_reported : FxHashSet ( ) ,
235233 nonlexical_regioncx : opt_regioncx. clone ( ) ,
236234 } ;
@@ -295,15 +293,12 @@ pub struct MirBorrowckCtxt<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
295293 /// I'm not sure this is the right approach - @eddyb could you try and
296294 /// figure this out?
297295 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 ) > ,
307302 /// This field keeps track of when borrow conflict errors are reported
308303 /// for reservations, so that we don't report seemingly duplicate
309304 /// errors for corresponding activations
@@ -730,21 +725,17 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
730725
731726 if let Activation ( _, borrow_index) = rw {
732727 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) ;
739730 return AccessErrorsReported {
740731 mutability_error : false ,
741732 conflict_error : true ,
742733 } ;
743734 }
744735 }
745736
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) ;
748739 return AccessErrorsReported {
749740 mutability_error : false ,
750741 conflict_error : true ,
@@ -756,8 +747,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
756747 let conflict_error =
757748 self . check_access_for_conflict ( context, place_span, sd, rw, flow_state) ;
758749
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 ) ) ;
761752 }
762753
763754 AccessErrorsReported {
@@ -845,15 +836,15 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
845836 place_span. 0
846837 ) ;
847838 this. reservation_error_reported . insert ( place_span. 0 . clone ( ) ) ;
848- }
839+ } ,
849840 Activation ( _, activating) => {
850841 debug ! (
851842 "observing check_place for activation of \
852843 borrow_index: {:?}",
853844 activating
854845 ) ;
855- }
856- Read ( ..) | Write ( ..) => { }
846+ } ,
847+ Read ( ..) | Write ( ..) => { } ,
857848 }
858849
859850 match kind {
0 commit comments