@@ -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,10 +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
- // Only downgrade errors on Rust 2015 and refuse to do so on Rust 2018.
263
- // FIXME(Centril): In Rust 1.40.0, refuse doing so on 2015 as well and
264
- // proceed to throwing out the migration infrastructure.
265
- disable_error_downgrading : body. span . rust_2018 ( ) ,
266
261
nonlexical_regioncx : regioncx,
267
262
used_mut : Default :: default ( ) ,
268
263
used_mut_upvars : SmallVec :: new ( ) ,
@@ -374,33 +369,6 @@ fn do_mir_borrowck<'a, 'tcx>(
374
369
if !mbcx. errors_buffer . is_empty ( ) {
375
370
mbcx. errors_buffer . sort_by_key ( |diag| diag. span . primary_span ( ) ) ;
376
371
377
- if !mbcx. disable_error_downgrading && tcx. migrate_borrowck ( ) {
378
- // When borrowck=migrate, check if AST-borrowck would
379
- // error on the given code.
380
-
381
- // rust-lang/rust#55492, rust-lang/rust#58776 check the base def id
382
- // for errors. AST borrowck is responsible for aggregating
383
- // `signalled_any_error` from all of the nested closures here.
384
- let base_def_id = tcx. closure_base_def_id ( def_id) ;
385
-
386
- match tcx. borrowck ( base_def_id) . signalled_any_error {
387
- SignalledError :: NoErrorsSeen => {
388
- // if AST-borrowck signalled no errors, then
389
- // downgrade all the buffered MIR-borrowck errors
390
- // to warnings.
391
-
392
- for err in mbcx. errors_buffer . iter_mut ( ) {
393
- downgrade_if_error ( err) ;
394
- }
395
- }
396
- SignalledError :: SawSomeError => {
397
- // if AST-borrowck signalled a (cancelled) error,
398
- // then we will just emit the buffered
399
- // MIR-borrowck errors as normal.
400
- }
401
- }
402
- }
403
-
404
372
for diag in mbcx. errors_buffer . drain ( ..) {
405
373
mbcx. infcx . tcx . sess . diagnostic ( ) . emit_diagnostic ( & diag) ;
406
374
}
@@ -416,21 +384,6 @@ fn do_mir_borrowck<'a, 'tcx>(
416
384
result
417
385
}
418
386
419
- fn downgrade_if_error ( diag : & mut Diagnostic ) {
420
- if diag. is_error ( ) {
421
- diag. level = Level :: Warning ;
422
- diag. warn (
423
- "this error has been downgraded to a warning for backwards \
424
- compatibility with previous releases",
425
- ) . warn (
426
- "this represents potential undefined behavior in your code and \
427
- this warning will become a hard error in the future",
428
- ) . note (
429
- "for more information, try `rustc --explain E0729`"
430
- ) ;
431
- }
432
- }
433
-
434
387
crate struct MirBorrowckCtxt < ' cx , ' tcx > {
435
388
crate infcx : & ' cx InferCtxt < ' cx , ' tcx > ,
436
389
body : & ' cx Body < ' tcx > ,
@@ -491,9 +444,6 @@ crate struct MirBorrowckCtxt<'cx, 'tcx> {
491
444
uninitialized_error_reported : FxHashSet < PlaceRef < ' cx , ' tcx > > ,
492
445
/// Errors to be reported buffer
493
446
errors_buffer : Vec < Diagnostic > ,
494
- /// If there are no errors reported by the HIR borrow checker, we downgrade
495
- /// all NLL errors to warnings. Setting this flag disables downgrading.
496
- disable_error_downgrading : bool ,
497
447
/// This field keeps track of all the local variables that are declared mut and are mutated.
498
448
/// Used for the warning issued by an unused mutable local variable.
499
449
used_mut : FxHashSet < Local > ,
@@ -934,12 +884,6 @@ impl InitializationRequiringAction {
934
884
}
935
885
936
886
impl < ' cx , ' tcx > MirBorrowckCtxt < ' cx , ' tcx > {
937
- /// If there are no errors reported by the HIR borrow checker, we downgrade
938
- /// all NLL errors to warnings. Calling this disables downgrading.
939
- crate fn disable_error_downgrading ( & mut self ) {
940
- self . disable_error_downgrading = true ;
941
- }
942
-
943
887
/// Checks an access to the given place to see if it is allowed. Examines the set of borrows
944
888
/// that are in scope, as well as which paths have been initialized, to ensure that (a) the
945
889
/// place is initialized and (b) it is not borrowed in some way that would prevent this
0 commit comments