@@ -7,7 +7,6 @@ use rustc::hir::def_id::DefId;
77use rustc:: infer:: InferCtxt ;
88use rustc:: lint:: builtin:: UNUSED_MUT ;
99use rustc:: lint:: builtin:: { MUTABLE_BORROW_RESERVATION_CONFLICT } ;
10- use rustc:: middle:: borrowck:: SignalledError ;
1110use rustc:: mir:: { AggregateKind , BasicBlock , BorrowCheckResult , BorrowKind } ;
1211use rustc:: mir:: {
1312 ClearCrossCrate , Local , Location , Body , Mutability , Operand , Place , PlaceBase , PlaceElem ,
@@ -18,7 +17,7 @@ use rustc::mir::{Terminator, TerminatorKind};
1817use rustc:: ty:: query:: Providers ;
1918use rustc:: ty:: { self , TyCtxt } ;
2019
21- use rustc_errors:: { Applicability , Diagnostic , DiagnosticBuilder , Level } ;
20+ use rustc_errors:: { Applicability , Diagnostic , DiagnosticBuilder } ;
2221use rustc_data_structures:: bit_set:: BitSet ;
2322use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
2423use rustc_data_structures:: graph:: dominators:: Dominators ;
@@ -259,10 +258,6 @@ fn do_mir_borrowck<'a, 'tcx>(
259258 move_error_reported : BTreeMap :: new ( ) ,
260259 uninitialized_error_reported : Default :: default ( ) ,
261260 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 ( ) ,
266261 nonlexical_regioncx : regioncx,
267262 used_mut : Default :: default ( ) ,
268263 used_mut_upvars : SmallVec :: new ( ) ,
@@ -374,33 +369,6 @@ fn do_mir_borrowck<'a, 'tcx>(
374369 if !mbcx. errors_buffer . is_empty ( ) {
375370 mbcx. errors_buffer . sort_by_key ( |diag| diag. span . primary_span ( ) ) ;
376371
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-
404372 for diag in mbcx. errors_buffer . drain ( ..) {
405373 mbcx. infcx . tcx . sess . diagnostic ( ) . emit_diagnostic ( & diag) ;
406374 }
@@ -416,21 +384,6 @@ fn do_mir_borrowck<'a, 'tcx>(
416384 result
417385}
418386
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-
434387crate struct MirBorrowckCtxt < ' cx , ' tcx > {
435388 crate infcx : & ' cx InferCtxt < ' cx , ' tcx > ,
436389 body : & ' cx Body < ' tcx > ,
@@ -491,9 +444,6 @@ crate struct MirBorrowckCtxt<'cx, 'tcx> {
491444 uninitialized_error_reported : FxHashSet < PlaceRef < ' cx , ' tcx > > ,
492445 /// Errors to be reported buffer
493446 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 ,
497447 /// This field keeps track of all the local variables that are declared mut and are mutated.
498448 /// Used for the warning issued by an unused mutable local variable.
499449 used_mut : FxHashSet < Local > ,
@@ -934,12 +884,6 @@ impl InitializationRequiringAction {
934884}
935885
936886impl < ' 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-
943887 /// Checks an access to the given place to see if it is allowed. Examines the set of borrows
944888 /// that are in scope, as well as which paths have been initialized, to ensure that (a) the
945889 /// place is initialized and (b) it is not borrowed in some way that would prevent this
0 commit comments