Skip to content

Commit 0c7c98f

Browse files
committed
rustc_mir: remove dead code for downgrading errors.
1 parent b6fc4b1 commit 0c7c98f

File tree

2 files changed

+1
-58
lines changed

2 files changed

+1
-58
lines changed

src/librustc_mir/borrow_check/conflict_errors.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
105105
format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()),
106106
);
107107

108-
// This error should not be downgraded to a warning,
109-
// even in migrate mode.
110-
self.disable_error_downgrading();
111108
err.buffer(&mut self.errors_buffer);
112109
} else {
113110
if let Some((reported_place, _)) = self.move_error_reported.get(&move_out_indices) {

src/librustc_mir/borrow_check/mod.rs

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use rustc::hir::def_id::DefId;
77
use rustc::infer::InferCtxt;
88
use rustc::lint::builtin::UNUSED_MUT;
99
use rustc::lint::builtin::{MUTABLE_BORROW_RESERVATION_CONFLICT};
10-
use rustc::middle::borrowck::SignalledError;
1110
use rustc::mir::{AggregateKind, BasicBlock, BorrowCheckResult, BorrowKind};
1211
use rustc::mir::{
1312
ClearCrossCrate, Local, Location, Body, Mutability, Operand, Place, PlaceBase, PlaceElem,
@@ -18,7 +17,7 @@ use rustc::mir::{Terminator, TerminatorKind};
1817
use rustc::ty::query::Providers;
1918
use rustc::ty::{self, TyCtxt};
2019

21-
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, Level};
20+
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder};
2221
use rustc_data_structures::bit_set::BitSet;
2322
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
2423
use rustc_data_structures::graph::dominators::Dominators;
@@ -259,8 +258,6 @@ fn do_mir_borrowck<'a, 'tcx>(
259258
move_error_reported: BTreeMap::new(),
260259
uninitialized_error_reported: Default::default(),
261260
errors_buffer,
262-
// FIXME(Centril): throw out the migration infrastructure.
263-
disable_error_downgrading: true,
264261
nonlexical_regioncx: regioncx,
265262
used_mut: Default::default(),
266263
used_mut_upvars: SmallVec::new(),
@@ -372,33 +369,6 @@ fn do_mir_borrowck<'a, 'tcx>(
372369
if !mbcx.errors_buffer.is_empty() {
373370
mbcx.errors_buffer.sort_by_key(|diag| diag.span.primary_span());
374371

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-
402372
for diag in mbcx.errors_buffer.drain(..) {
403373
mbcx.infcx.tcx.sess.diagnostic().emit_diagnostic(&diag);
404374
}
@@ -414,21 +384,6 @@ fn do_mir_borrowck<'a, 'tcx>(
414384
result
415385
}
416386

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-
432387
crate struct MirBorrowckCtxt<'cx, 'tcx> {
433388
crate infcx: &'cx InferCtxt<'cx, 'tcx>,
434389
body: &'cx Body<'tcx>,
@@ -489,9 +444,6 @@ crate struct MirBorrowckCtxt<'cx, 'tcx> {
489444
uninitialized_error_reported: FxHashSet<PlaceRef<'cx, 'tcx>>,
490445
/// Errors to be reported buffer
491446
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,
495447
/// This field keeps track of all the local variables that are declared mut and are mutated.
496448
/// Used for the warning issued by an unused mutable local variable.
497449
used_mut: FxHashSet<Local>,
@@ -932,12 +884,6 @@ impl InitializationRequiringAction {
932884
}
933885

934886
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-
941887
/// Checks an access to the given place to see if it is allowed. Examines the set of borrows
942888
/// that are in scope, as well as which paths have been initialized, to ensure that (a) the
943889
/// place is initialized and (b) it is not borrowed in some way that would prevent this

0 commit comments

Comments
 (0)