@@ -35,14 +35,13 @@ use rustc_middle::mir::{Field, ProjectionElem, Promoted, Rvalue, Statement, Stat
35
35
use rustc_middle:: mir:: { InlineAsmOperand , Terminator , TerminatorKind } ;
36
36
use rustc_middle:: ty:: query:: Providers ;
37
37
use 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 } ;
40
40
41
41
use either:: Either ;
42
42
use smallvec:: SmallVec ;
43
43
use std:: cell:: RefCell ;
44
44
use std:: collections:: BTreeMap ;
45
- use std:: mem;
46
45
use std:: rc:: Rc ;
47
46
48
47
use rustc_mir_dataflow:: impls:: {
@@ -313,7 +312,6 @@ fn do_mir_borrowck<'a, 'tcx>(
313
312
locals_are_invalidated_at_exit,
314
313
access_place_error_reported : Default :: default ( ) ,
315
314
reservation_error_reported : Default :: default ( ) ,
316
- reservation_warnings : Default :: default ( ) ,
317
315
uninitialized_error_reported : Default :: default ( ) ,
318
316
regioncx : regioncx. clone ( ) ,
319
317
used_mut : Default :: default ( ) ,
@@ -345,7 +343,6 @@ fn do_mir_borrowck<'a, 'tcx>(
345
343
fn_self_span_reported : Default :: default ( ) ,
346
344
access_place_error_reported : Default :: default ( ) ,
347
345
reservation_error_reported : Default :: default ( ) ,
348
- reservation_warnings : Default :: default ( ) ,
349
346
uninitialized_error_reported : Default :: default ( ) ,
350
347
regioncx : Rc :: clone ( & regioncx) ,
351
348
used_mut : Default :: default ( ) ,
@@ -378,34 +375,6 @@ fn do_mir_borrowck<'a, 'tcx>(
378
375
& mut mbcx,
379
376
) ;
380
377
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
-
409
378
// For each non-user used mutable variable, check if it's been assigned from
410
379
// a user-declared local. If so, then put that local into the used_mut set.
411
380
// Note that this set is expected to be small - only upvars from closures
@@ -540,11 +509,6 @@ struct MirBorrowckCtxt<'cx, 'tcx> {
540
509
/// used to report extra information for `FnSelfUse`, to avoid
541
510
/// unnecessarily verbose errors.
542
511
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 > ) > ,
548
512
/// This field keeps track of errors reported in the checking of uninitialized variables,
549
513
/// so that we don't report seemingly duplicate errors.
550
514
uninitialized_error_reported : FxHashSet < PlaceRef < ' tcx > > ,
@@ -996,12 +960,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
996
960
let conflict_error =
997
961
self . check_access_for_conflict ( location, place_span, sd, rw, flow_state) ;
998
962
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
-
1005
963
if conflict_error || mutability_error {
1006
964
debug ! ( "access_place: logging error place_span=`{:?}` kind=`{:?}`" , place_span, kind) ;
1007
965
self . access_place_error_reported . insert ( ( place_span. 0 , place_span. 1 ) ) ;
@@ -1068,6 +1026,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1068
1026
BorrowKind :: Unique | BorrowKind :: Mut { .. } ,
1069
1027
) => Control :: Continue ,
1070
1028
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
+
1071
1035
( Write ( WriteKind :: Move ) , BorrowKind :: Shallow ) => {
1072
1036
// Handled by initialization checks.
1073
1037
Control :: Continue
@@ -1096,27 +1060,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1096
1060
Control :: Break
1097
1061
}
1098
1062
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
-
1120
1063
( Reservation ( kind) | Activation ( kind, _) | Write ( kind) , _) => {
1121
1064
match rw {
1122
1065
Reservation ( ..) => {
0 commit comments