@@ -7,7 +7,6 @@ use rustc::hir::def_id::DefId;
7
7
use rustc:: infer:: InferCtxt ;
8
8
use rustc:: lint:: builtin:: UNUSED_MUT ;
9
9
use rustc:: lint:: builtin:: { MUTABLE_BORROW_RESERVATION_CONFLICT } ;
10
- use rustc:: middle:: borrowck:: SignalledError ;
11
10
use rustc:: mir:: { AggregateKind , BasicBlock , BorrowCheckResult , BorrowKind } ;
12
11
use rustc:: mir:: {
13
12
ClearCrossCrate , Local , Location , Body , Mutability , Operand , Place , PlaceBase , PlaceElem ,
@@ -18,7 +17,7 @@ use rustc::mir::{Terminator, TerminatorKind};
18
17
use rustc:: ty:: query:: Providers ;
19
18
use rustc:: ty:: { self , TyCtxt } ;
20
19
21
- use rustc_errors:: { Applicability , Diagnostic , DiagnosticBuilder , Level } ;
20
+ use rustc_errors:: { Applicability , Diagnostic , DiagnosticBuilder } ;
22
21
use rustc_data_structures:: bit_set:: BitSet ;
23
22
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
24
23
use rustc_data_structures:: graph:: dominators:: Dominators ;
@@ -259,8 +258,6 @@ fn do_mir_borrowck<'a, 'tcx>(
259
258
move_error_reported : BTreeMap :: new ( ) ,
260
259
uninitialized_error_reported : Default :: default ( ) ,
261
260
errors_buffer,
262
- // FIXME(Centril): throw out the migration infrastructure.
263
- disable_error_downgrading : true ,
264
261
nonlexical_regioncx : regioncx,
265
262
used_mut : Default :: default ( ) ,
266
263
used_mut_upvars : SmallVec :: new ( ) ,
@@ -372,33 +369,6 @@ fn do_mir_borrowck<'a, 'tcx>(
372
369
if !mbcx. errors_buffer . is_empty ( ) {
373
370
mbcx. errors_buffer . sort_by_key ( |diag| diag. span . primary_span ( ) ) ;
374
371
375
- if !mbcx. disable_error_downgrading && tcx. migrate_borrowck ( ) {
376
- // When borrowck=migrate, check if AST-borrowck would
377
- // error on the given code.
378
-
379
- // rust-lang/rust#55492, rust-lang/rust#58776 check the base def id
380
- // for errors. AST borrowck is responsible for aggregating
381
- // `signalled_any_error` from all of the nested closures here.
382
- let base_def_id = tcx. closure_base_def_id ( def_id) ;
383
-
384
- match tcx. borrowck ( base_def_id) . signalled_any_error {
385
- SignalledError :: NoErrorsSeen => {
386
- // if AST-borrowck signalled no errors, then
387
- // downgrade all the buffered MIR-borrowck errors
388
- // to warnings.
389
-
390
- for err in mbcx. errors_buffer . iter_mut ( ) {
391
- downgrade_if_error ( err) ;
392
- }
393
- }
394
- SignalledError :: SawSomeError => {
395
- // if AST-borrowck signalled a (cancelled) error,
396
- // then we will just emit the buffered
397
- // MIR-borrowck errors as normal.
398
- }
399
- }
400
- }
401
-
402
372
for diag in mbcx. errors_buffer . drain ( ..) {
403
373
mbcx. infcx . tcx . sess . diagnostic ( ) . emit_diagnostic ( & diag) ;
404
374
}
@@ -414,21 +384,6 @@ fn do_mir_borrowck<'a, 'tcx>(
414
384
result
415
385
}
416
386
417
- fn downgrade_if_error ( diag : & mut Diagnostic ) {
418
- if diag. is_error ( ) {
419
- diag. level = Level :: Warning ;
420
- diag. warn (
421
- "this error has been downgraded to a warning for backwards \
422
- compatibility with previous releases",
423
- ) . warn (
424
- "this represents potential undefined behavior in your code and \
425
- this warning will become a hard error in the future",
426
- ) . note (
427
- "for more information, try `rustc --explain E0729`"
428
- ) ;
429
- }
430
- }
431
-
432
387
crate struct MirBorrowckCtxt < ' cx , ' tcx > {
433
388
crate infcx : & ' cx InferCtxt < ' cx , ' tcx > ,
434
389
body : & ' cx Body < ' tcx > ,
@@ -489,9 +444,6 @@ crate struct MirBorrowckCtxt<'cx, 'tcx> {
489
444
uninitialized_error_reported : FxHashSet < PlaceRef < ' cx , ' tcx > > ,
490
445
/// Errors to be reported buffer
491
446
errors_buffer : Vec < Diagnostic > ,
492
- /// If there are no errors reported by the HIR borrow checker, we downgrade
493
- /// all NLL errors to warnings. Setting this flag disables downgrading.
494
- disable_error_downgrading : bool ,
495
447
/// This field keeps track of all the local variables that are declared mut and are mutated.
496
448
/// Used for the warning issued by an unused mutable local variable.
497
449
used_mut : FxHashSet < Local > ,
@@ -932,12 +884,6 @@ impl InitializationRequiringAction {
932
884
}
933
885
934
886
impl < ' cx , ' tcx > MirBorrowckCtxt < ' cx , ' tcx > {
935
- /// If there are no errors reported by the HIR borrow checker, we downgrade
936
- /// all NLL errors to warnings. Calling this disables downgrading.
937
- crate fn disable_error_downgrading ( & mut self ) {
938
- self . disable_error_downgrading = true ;
939
- }
940
-
941
887
/// Checks an access to the given place to see if it is allowed. Examines the set of borrows
942
888
/// that are in scope, as well as which paths have been initialized, to ensure that (a) the
943
889
/// place is initialized and (b) it is not borrowed in some way that would prevent this
0 commit comments