diff --git a/src/librustc/arena.rs b/src/librustc/arena.rs index d4fc1b12830..5d06f62f446 100644 --- a/src/librustc/arena.rs +++ b/src/librustc/arena.rs @@ -86,7 +86,6 @@ macro_rules! arena_types { rustc::infer::canonical::QueryResponse<'tcx, rustc::ty::Ty<'tcx>> >, [few] crate_inherent_impls: rustc::ty::CrateInherentImpls, - [decode] borrowck: rustc::middle::borrowck::BorrowCheckResult, [few] upstream_monomorphizations: rustc::util::nodemap::DefIdMap< rustc_data_structures::fx::FxHashMap< diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index ca07496afed..81183dc1f79 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -93,6 +93,8 @@ impl SuppressRegionErrors { /// checks, so we should ignore errors if NLL is (unconditionally) /// enabled. pub fn when_nll_is_enabled(tcx: TyCtxt<'_>) -> Self { + // FIXME(Centril): Once we actually remove `::Migrate` also make + // this always `true` and then proceed to eliminate the dead code. match tcx.borrowck_mode() { // If we're on Migrate mode, report AST region errors BorrowckMode::Migrate => SuppressRegionErrors { suppressed: false }, diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 7a01ae6b6d9..bd9899b644b 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -100,7 +100,6 @@ pub mod infer; pub mod lint; pub mod middle { - pub mod borrowck; pub mod expr_use_visitor; pub mod cstore; pub mod dead; diff --git a/src/librustc/middle/borrowck.rs b/src/librustc/middle/borrowck.rs deleted file mode 100644 index 60c24eeae7b..00000000000 --- a/src/librustc/middle/borrowck.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::ich::StableHashingContext; - -use rustc_data_structures::stable_hasher::{HashStable, StableHasher, - StableHasherResult}; - -#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable)] -pub enum SignalledError { SawSomeError, NoErrorsSeen } - -impl Default for SignalledError { - fn default() -> SignalledError { - SignalledError::NoErrorsSeen - } -} - -impl_stable_hash_for!(enum self::SignalledError { SawSomeError, NoErrorsSeen }); - -#[derive(Debug, Default, RustcEncodable, RustcDecodable)] -pub struct BorrowCheckResult { - pub signalled_any_error: SignalledError, -} - -impl<'a> HashStable> for BorrowCheckResult { - fn hash_stable(&self, - hcx: &mut StableHashingContext<'a>, - hasher: &mut StableHasher) { - let BorrowCheckResult { - ref signalled_any_error, - } = *self; - signalled_any_error.hash_stable(hcx, hasher); - } -} diff --git a/src/librustc/query/mod.rs b/src/librustc/query/mod.rs index 6de351fa13a..4b1558592ae 100644 --- a/src/librustc/query/mod.rs +++ b/src/librustc/query/mod.rs @@ -397,10 +397,6 @@ rustc_queries! { } BorrowChecking { - query borrowck(key: DefId) -> &'tcx BorrowCheckResult { - cache_on_disk_if { key.is_local() } - } - /// Borrow-checks the function body. If this is a closure, returns /// additional requirements that the closure's creator must verify. query mir_borrowck(key: DefId) -> mir::BorrowCheckResult<'tcx> { diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index b4fe550067a..cbb22f1e448 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -478,14 +478,6 @@ impl BorrowckMode { BorrowckMode::Migrate => true, } } - - /// Returns whether we should emit the AST-based borrow checker errors. - pub fn use_ast(self) -> bool { - match self { - BorrowckMode::Mir => false, - BorrowckMode::Migrate => false, - } - } } pub enum Input { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 3c511cb4d18..ad3fee17166 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1435,12 +1435,6 @@ impl<'tcx> TyCtxt<'tcx> { self.queries.on_disk_cache.serialize(self.global_tcx(), encoder) } - /// If `true`, we should use the AST-based borrowck (we may *also* use - /// the MIR-based borrowck). - pub fn use_ast_borrowck(self) -> bool { - self.borrowck_mode().use_ast() - } - /// If `true`, we should use the MIR-based borrowck, but also /// fall back on the AST borrowck if the MIR-based one errors. pub fn migrate_borrowck(self) -> bool { diff --git a/src/librustc/ty/query/mod.rs b/src/librustc/ty/query/mod.rs index f4b99ca3688..f559cde4b03 100644 --- a/src/librustc/ty/query/mod.rs +++ b/src/librustc/ty/query/mod.rs @@ -4,7 +4,6 @@ use crate::hir::def::{DefKind, Export}; use crate::hir::{self, TraitCandidate, ItemLocalId, CodegenFnAttrs}; use crate::infer::canonical::{self, Canonical}; use crate::lint; -use crate::middle::borrowck::BorrowCheckResult; use crate::middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary, ForeignModule}; use crate::middle::cstore::{NativeLibraryKind, DepKind, CrateSource}; use crate::middle::privacy::AccessLevels; diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 067ab080713..70a2526f70a 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -1932,48 +1932,26 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } } - Reservation(wk @ WriteKind::Move) - | Write(wk @ WriteKind::Move) - | Reservation(wk @ WriteKind::StorageDeadOrDrop) - | Reservation(wk @ WriteKind::MutableBorrow(BorrowKind::Shared)) - | Reservation(wk @ WriteKind::MutableBorrow(BorrowKind::Shallow)) - | Write(wk @ WriteKind::StorageDeadOrDrop) - | Write(wk @ WriteKind::MutableBorrow(BorrowKind::Shared)) - | Write(wk @ WriteKind::MutableBorrow(BorrowKind::Shallow)) => { - if let (Err(place_err), true) = ( + Reservation(WriteKind::Move) + | Write(WriteKind::Move) + | Reservation(WriteKind::StorageDeadOrDrop) + | Reservation(WriteKind::MutableBorrow(BorrowKind::Shared)) + | Reservation(WriteKind::MutableBorrow(BorrowKind::Shallow)) + | Write(WriteKind::StorageDeadOrDrop) + | Write(WriteKind::MutableBorrow(BorrowKind::Shared)) + | Write(WriteKind::MutableBorrow(BorrowKind::Shallow)) => { + if let (Err(_), true) = ( self.is_mutable(place.as_ref(), is_local_mutation_allowed), self.errors_buffer.is_empty() ) { - if self.infcx.tcx.migrate_borrowck() { - // rust-lang/rust#46908: In pure NLL mode this - // code path should be unreachable (and thus - // we signal an ICE in the else branch - // here). But we can legitimately get here - // under borrowck=migrate mode, so instead of - // ICE'ing we instead report a legitimate - // error (which will then be downgraded to a - // warning by the migrate machinery). - error_access = match wk { - WriteKind::MutableBorrow(_) => AccessKind::MutableBorrow, - WriteKind::Move => AccessKind::Move, - WriteKind::StorageDeadOrDrop | - WriteKind::Mutate => AccessKind::Mutate, - }; - self.report_mutability_error( - place, - span, - place_err, - error_access, - location, - ); - } else { - span_bug!( - span, - "Accessing `{:?}` with the kind `{:?}` shouldn't be possible", - place, - kind, - ); - } + // rust-lang/rust#46908: In pure NLL mode this code path should + // be unreachable (and thus we signal an ICE in the else branch here). + span_bug!( + span, + "Accessing `{:?}` with the kind `{:?}` shouldn't be possible", + place, + kind, + ); } return false; } diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index a9c66b3c8c6..d7b6810a865 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -28,17 +28,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateDrops { let param_env = tcx.param_env(src.def_id()).with_reveal_all(); let move_data = match MoveData::gather_moves(body, tcx) { Ok(move_data) => move_data, - Err((move_data, _move_errors)) => { - // The only way we should be allowing any move_errors - // in here is if we are in the migration path for the - // NLL-based MIR-borrowck. - // - // If we are in the migration path, we have already - // reported these errors as warnings to the user. So - // we will just ignore them here. - assert!(tcx.migrate_borrowck()); - move_data - } + Err(_) => bug!("No `move_errors` should be allowed in MIR borrowck"), }; let elaborate_patch = { let body = &*body; diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index ac291c2996d..0da1f3a1aff 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -291,10 +291,6 @@ fn optimized_mir(tcx: TyCtxt<'_>, def_id: DefId) -> &Body<'_> { // execute before we can steal. tcx.ensure().mir_borrowck(def_id); - if tcx.use_ast_borrowck() { - tcx.ensure().borrowck(def_id); - } - let (body, _) = tcx.mir_validated(def_id); let mut body = body.steal(); run_optimization_passes(tcx, &mut body, def_id, None);