@@ -35,14 +35,13 @@ use rustc_middle::mir::{Field, ProjectionElem, Promoted, Rvalue, Statement, Stat
3535use rustc_middle:: mir:: { InlineAsmOperand , Terminator , TerminatorKind } ;
3636use rustc_middle:: ty:: query:: Providers ;
3737use rustc_middle:: ty:: { self , CapturedPlace , ParamEnv , RegionVid , TyCtxt } ;
38- use rustc_session:: lint:: builtin:: { MUTABLE_BORROW_RESERVATION_CONFLICT , UNUSED_MUT } ;
39- use rustc_span:: { Span , Symbol , DUMMY_SP } ;
38+ use rustc_session:: lint:: builtin:: UNUSED_MUT ;
39+ use rustc_span:: { Span , Symbol } ;
4040
4141use either:: Either ;
4242use smallvec:: SmallVec ;
4343use std:: cell:: RefCell ;
4444use std:: collections:: BTreeMap ;
45- use std:: mem;
4645use std:: rc:: Rc ;
4746
4847use rustc_mir_dataflow:: impls:: {
@@ -313,7 +312,6 @@ fn do_mir_borrowck<'a, 'tcx>(
313312 locals_are_invalidated_at_exit,
314313 access_place_error_reported : Default :: default ( ) ,
315314 reservation_error_reported : Default :: default ( ) ,
316- reservation_warnings : Default :: default ( ) ,
317315 uninitialized_error_reported : Default :: default ( ) ,
318316 regioncx : regioncx. clone ( ) ,
319317 used_mut : Default :: default ( ) ,
@@ -345,7 +343,6 @@ fn do_mir_borrowck<'a, 'tcx>(
345343 fn_self_span_reported : Default :: default ( ) ,
346344 access_place_error_reported : Default :: default ( ) ,
347345 reservation_error_reported : Default :: default ( ) ,
348- reservation_warnings : Default :: default ( ) ,
349346 uninitialized_error_reported : Default :: default ( ) ,
350347 regioncx : Rc :: clone ( & regioncx) ,
351348 used_mut : Default :: default ( ) ,
@@ -378,34 +375,6 @@ fn do_mir_borrowck<'a, 'tcx>(
378375 & mut mbcx,
379376 ) ;
380377
381- // Convert any reservation warnings into lints.
382- let reservation_warnings = mem:: take ( & mut mbcx. reservation_warnings ) ;
383- for ( _, ( place, span, location, bk, borrow) ) in reservation_warnings {
384- let initial_diag = mbcx. report_conflicting_borrow ( location, ( place, span) , bk, & borrow) ;
385-
386- let scope = mbcx. body . source_info ( location) . scope ;
387- let lint_root = match & mbcx. body . source_scopes [ scope] . local_data {
388- ClearCrossCrate :: Set ( data) => data. lint_root ,
389- _ => tcx. hir ( ) . local_def_id_to_hir_id ( def. did ) ,
390- } ;
391-
392- // Span and message don't matter; we overwrite them below anyway
393- mbcx. infcx . tcx . struct_span_lint_hir (
394- MUTABLE_BORROW_RESERVATION_CONFLICT ,
395- lint_root,
396- DUMMY_SP ,
397- |lint| {
398- let mut diag = lint. build ( "" ) ;
399-
400- diag. message = initial_diag. styled_message ( ) . clone ( ) ;
401- diag. span = initial_diag. span . clone ( ) ;
402-
403- mbcx. buffer_non_error_diag ( diag) ;
404- } ,
405- ) ;
406- initial_diag. cancel ( ) ;
407- }
408-
409378 // For each non-user used mutable variable, check if it's been assigned from
410379 // a user-declared local. If so, then put that local into the used_mut set.
411380 // Note that this set is expected to be small - only upvars from closures
@@ -540,11 +509,6 @@ struct MirBorrowckCtxt<'cx, 'tcx> {
540509 /// used to report extra information for `FnSelfUse`, to avoid
541510 /// unnecessarily verbose errors.
542511 fn_self_span_reported : FxHashSet < Span > ,
543- /// Migration warnings to be reported for #56254. We delay reporting these
544- /// so that we can suppress the warning if there's a corresponding error
545- /// for the activation of the borrow.
546- reservation_warnings :
547- FxHashMap < BorrowIndex , ( Place < ' tcx > , Span , Location , BorrowKind , BorrowData < ' tcx > ) > ,
548512 /// This field keeps track of errors reported in the checking of uninitialized variables,
549513 /// so that we don't report seemingly duplicate errors.
550514 uninitialized_error_reported : FxHashSet < PlaceRef < ' tcx > > ,
@@ -996,12 +960,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
996960 let conflict_error =
997961 self . check_access_for_conflict ( location, place_span, sd, rw, flow_state) ;
998962
999- if let ( Activation ( _, borrow_idx) , true ) = ( kind. 1 , conflict_error) {
1000- // Suppress this warning when there's an error being emitted for the
1001- // same borrow: fixing the error is likely to fix the warning.
1002- self . reservation_warnings . remove ( & borrow_idx) ;
1003- }
1004-
1005963 if conflict_error || mutability_error {
1006964 debug ! ( "access_place: logging error place_span=`{:?}` kind=`{:?}`" , place_span, kind) ;
1007965 self . access_place_error_reported . insert ( ( place_span. 0 , place_span. 1 ) ) ;
@@ -1068,6 +1026,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10681026 BorrowKind :: Unique | BorrowKind :: Mut { .. } ,
10691027 ) => Control :: Continue ,
10701028
1029+ ( Reservation ( _) , BorrowKind :: Shallow | BorrowKind :: Shared ) => {
1030+ // This used to be a future compatibility warning (to be
1031+ // disallowed on NLL). See rust-lang/rust#56254
1032+ Control :: Continue
1033+ }
1034+
10711035 ( Write ( WriteKind :: Move ) , BorrowKind :: Shallow ) => {
10721036 // Handled by initialization checks.
10731037 Control :: Continue
@@ -1096,27 +1060,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10961060 Control :: Break
10971061 }
10981062
1099- (
1100- Reservation ( WriteKind :: MutableBorrow ( bk) ) ,
1101- BorrowKind :: Shallow | BorrowKind :: Shared ,
1102- ) if { tcx. migrate_borrowck ( ) && this. borrow_set . contains ( & location) } => {
1103- let bi = this. borrow_set . get_index_of ( & location) . unwrap ( ) ;
1104- debug ! (
1105- "recording invalid reservation of place: {:?} with \
1106- borrow index {:?} as warning",
1107- place_span. 0 , bi,
1108- ) ;
1109- // rust-lang/rust#56254 - This was previously permitted on
1110- // the 2018 edition so we emit it as a warning. We buffer
1111- // these separately so that we only emit a warning if borrow
1112- // checking was otherwise successful.
1113- this. reservation_warnings
1114- . insert ( bi, ( place_span. 0 , place_span. 1 , location, bk, borrow. clone ( ) ) ) ;
1115-
1116- // Don't suppress actual errors.
1117- Control :: Continue
1118- }
1119-
11201063 ( Reservation ( kind) | Activation ( kind, _) | Write ( kind) , _) => {
11211064 match rw {
11221065 Reservation ( ..) => {
0 commit comments