@@ -34,14 +34,13 @@ use rustc_middle::mir::{Field, ProjectionElem, Promoted, Rvalue, Statement, Stat
34
34
use rustc_middle:: mir:: { InlineAsmOperand , Terminator , TerminatorKind } ;
35
35
use rustc_middle:: ty:: query:: Providers ;
36
36
use rustc_middle:: ty:: { self , CapturedPlace , ParamEnv , RegionVid , TyCtxt } ;
37
- use rustc_session:: lint:: builtin:: { MUTABLE_BORROW_RESERVATION_CONFLICT , UNUSED_MUT } ;
38
- use rustc_span:: { Span , Symbol , DUMMY_SP } ;
37
+ use rustc_session:: lint:: builtin:: UNUSED_MUT ;
38
+ use rustc_span:: { Span , Symbol } ;
39
39
40
40
use either:: Either ;
41
41
use smallvec:: SmallVec ;
42
42
use std:: cell:: RefCell ;
43
43
use std:: collections:: BTreeMap ;
44
- use std:: mem;
45
44
use std:: rc:: Rc ;
46
45
47
46
use rustc_mir_dataflow:: impls:: {
@@ -312,7 +311,6 @@ fn do_mir_borrowck<'a, 'tcx>(
312
311
locals_are_invalidated_at_exit,
313
312
access_place_error_reported : Default :: default ( ) ,
314
313
reservation_error_reported : Default :: default ( ) ,
315
- reservation_warnings : Default :: default ( ) ,
316
314
uninitialized_error_reported : Default :: default ( ) ,
317
315
regioncx : regioncx. clone ( ) ,
318
316
used_mut : Default :: default ( ) ,
@@ -344,7 +342,6 @@ fn do_mir_borrowck<'a, 'tcx>(
344
342
fn_self_span_reported : Default :: default ( ) ,
345
343
access_place_error_reported : Default :: default ( ) ,
346
344
reservation_error_reported : Default :: default ( ) ,
347
- reservation_warnings : Default :: default ( ) ,
348
345
uninitialized_error_reported : Default :: default ( ) ,
349
346
regioncx : Rc :: clone ( & regioncx) ,
350
347
used_mut : Default :: default ( ) ,
@@ -377,34 +374,6 @@ fn do_mir_borrowck<'a, 'tcx>(
377
374
& mut mbcx,
378
375
) ;
379
376
380
- // Convert any reservation warnings into lints.
381
- let reservation_warnings = mem:: take ( & mut mbcx. reservation_warnings ) ;
382
- for ( _, ( place, span, location, bk, borrow) ) in reservation_warnings {
383
- let initial_diag = mbcx. report_conflicting_borrow ( location, ( place, span) , bk, & borrow) ;
384
-
385
- let scope = mbcx. body . source_info ( location) . scope ;
386
- let lint_root = match & mbcx. body . source_scopes [ scope] . local_data {
387
- ClearCrossCrate :: Set ( data) => data. lint_root ,
388
- _ => tcx. hir ( ) . local_def_id_to_hir_id ( def. did ) ,
389
- } ;
390
-
391
- // Span and message don't matter; we overwrite them below anyway
392
- mbcx. infcx . tcx . struct_span_lint_hir (
393
- MUTABLE_BORROW_RESERVATION_CONFLICT ,
394
- lint_root,
395
- DUMMY_SP ,
396
- |lint| {
397
- let mut diag = lint. build ( "" ) ;
398
-
399
- diag. message = initial_diag. styled_message ( ) . clone ( ) ;
400
- diag. span = initial_diag. span . clone ( ) ;
401
-
402
- mbcx. buffer_non_error_diag ( diag) ;
403
- } ,
404
- ) ;
405
- initial_diag. cancel ( ) ;
406
- }
407
-
408
377
// For each non-user used mutable variable, check if it's been assigned from
409
378
// a user-declared local. If so, then put that local into the used_mut set.
410
379
// Note that this set is expected to be small - only upvars from closures
@@ -539,11 +508,6 @@ struct MirBorrowckCtxt<'cx, 'tcx> {
539
508
/// used to report extra information for `FnSelfUse`, to avoid
540
509
/// unnecessarily verbose errors.
541
510
fn_self_span_reported : FxHashSet < Span > ,
542
- /// Migration warnings to be reported for #56254. We delay reporting these
543
- /// so that we can suppress the warning if there's a corresponding error
544
- /// for the activation of the borrow.
545
- reservation_warnings :
546
- FxHashMap < BorrowIndex , ( Place < ' tcx > , Span , Location , BorrowKind , BorrowData < ' tcx > ) > ,
547
511
/// This field keeps track of errors reported in the checking of uninitialized variables,
548
512
/// so that we don't report seemingly duplicate errors.
549
513
uninitialized_error_reported : FxHashSet < PlaceRef < ' tcx > > ,
@@ -995,12 +959,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
995
959
let conflict_error =
996
960
self . check_access_for_conflict ( location, place_span, sd, rw, flow_state) ;
997
961
998
- if let ( Activation ( _, borrow_idx) , true ) = ( kind. 1 , conflict_error) {
999
- // Suppress this warning when there's an error being emitted for the
1000
- // same borrow: fixing the error is likely to fix the warning.
1001
- self . reservation_warnings . remove ( & borrow_idx) ;
1002
- }
1003
-
1004
962
if conflict_error || mutability_error {
1005
963
debug ! ( "access_place: logging error place_span=`{:?}` kind=`{:?}`" , place_span, kind) ;
1006
964
self . access_place_error_reported . insert ( ( place_span. 0 , place_span. 1 ) ) ;
@@ -1067,6 +1025,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1067
1025
BorrowKind :: Unique | BorrowKind :: Mut { .. } ,
1068
1026
) => Control :: Continue ,
1069
1027
1028
+ ( Reservation ( _) , BorrowKind :: Shallow | BorrowKind :: Shared ) => {
1029
+ // This used to be a future compatibility warning (to be
1030
+ // disallowed on NLL). See rust-lang/rust#56254
1031
+ Control :: Continue
1032
+ }
1033
+
1070
1034
( Write ( WriteKind :: Move ) , BorrowKind :: Shallow ) => {
1071
1035
// Handled by initialization checks.
1072
1036
Control :: Continue
@@ -1095,27 +1059,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1095
1059
Control :: Break
1096
1060
}
1097
1061
1098
- (
1099
- Reservation ( WriteKind :: MutableBorrow ( bk) ) ,
1100
- BorrowKind :: Shallow | BorrowKind :: Shared ,
1101
- ) if { tcx. migrate_borrowck ( ) && this. borrow_set . contains ( & location) } => {
1102
- let bi = this. borrow_set . get_index_of ( & location) . unwrap ( ) ;
1103
- debug ! (
1104
- "recording invalid reservation of place: {:?} with \
1105
- borrow index {:?} as warning",
1106
- place_span. 0 , bi,
1107
- ) ;
1108
- // rust-lang/rust#56254 - This was previously permitted on
1109
- // the 2018 edition so we emit it as a warning. We buffer
1110
- // these separately so that we only emit a warning if borrow
1111
- // checking was otherwise successful.
1112
- this. reservation_warnings
1113
- . insert ( bi, ( place_span. 0 , place_span. 1 , location, bk, borrow. clone ( ) ) ) ;
1114
-
1115
- // Don't suppress actual errors.
1116
- Control :: Continue
1117
- }
1118
-
1119
1062
( Reservation ( kind) | Activation ( kind, _) | Write ( kind) , _) => {
1120
1063
match rw {
1121
1064
Reservation ( ..) => {
0 commit comments