cleanup dead ast-borrowck / migrate-mode code.
This commit is contained in:
parent
defd5088d6
commit
dfd365f3e4
11 changed files with 20 additions and 106 deletions
|
@ -86,7 +86,6 @@ macro_rules! arena_types {
|
||||||
rustc::infer::canonical::QueryResponse<'tcx, rustc::ty::Ty<'tcx>>
|
rustc::infer::canonical::QueryResponse<'tcx, rustc::ty::Ty<'tcx>>
|
||||||
>,
|
>,
|
||||||
[few] crate_inherent_impls: rustc::ty::CrateInherentImpls,
|
[few] crate_inherent_impls: rustc::ty::CrateInherentImpls,
|
||||||
[decode] borrowck: rustc::middle::borrowck::BorrowCheckResult,
|
|
||||||
[few] upstream_monomorphizations:
|
[few] upstream_monomorphizations:
|
||||||
rustc::util::nodemap::DefIdMap<
|
rustc::util::nodemap::DefIdMap<
|
||||||
rustc_data_structures::fx::FxHashMap<
|
rustc_data_structures::fx::FxHashMap<
|
||||||
|
|
|
@ -93,6 +93,8 @@ impl SuppressRegionErrors {
|
||||||
/// checks, so we should ignore errors if NLL is (unconditionally)
|
/// checks, so we should ignore errors if NLL is (unconditionally)
|
||||||
/// enabled.
|
/// enabled.
|
||||||
pub fn when_nll_is_enabled(tcx: TyCtxt<'_>) -> Self {
|
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() {
|
match tcx.borrowck_mode() {
|
||||||
// If we're on Migrate mode, report AST region errors
|
// If we're on Migrate mode, report AST region errors
|
||||||
BorrowckMode::Migrate => SuppressRegionErrors { suppressed: false },
|
BorrowckMode::Migrate => SuppressRegionErrors { suppressed: false },
|
||||||
|
|
|
@ -100,7 +100,6 @@ pub mod infer;
|
||||||
pub mod lint;
|
pub mod lint;
|
||||||
|
|
||||||
pub mod middle {
|
pub mod middle {
|
||||||
pub mod borrowck;
|
|
||||||
pub mod expr_use_visitor;
|
pub mod expr_use_visitor;
|
||||||
pub mod cstore;
|
pub mod cstore;
|
||||||
pub mod dead;
|
pub mod dead;
|
||||||
|
|
|
@ -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<StableHashingContext<'a>> for BorrowCheckResult {
|
|
||||||
fn hash_stable<W: StableHasherResult>(&self,
|
|
||||||
hcx: &mut StableHashingContext<'a>,
|
|
||||||
hasher: &mut StableHasher<W>) {
|
|
||||||
let BorrowCheckResult {
|
|
||||||
ref signalled_any_error,
|
|
||||||
} = *self;
|
|
||||||
signalled_any_error.hash_stable(hcx, hasher);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -397,10 +397,6 @@ rustc_queries! {
|
||||||
}
|
}
|
||||||
|
|
||||||
BorrowChecking {
|
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
|
/// Borrow-checks the function body. If this is a closure, returns
|
||||||
/// additional requirements that the closure's creator must verify.
|
/// additional requirements that the closure's creator must verify.
|
||||||
query mir_borrowck(key: DefId) -> mir::BorrowCheckResult<'tcx> {
|
query mir_borrowck(key: DefId) -> mir::BorrowCheckResult<'tcx> {
|
||||||
|
|
|
@ -478,14 +478,6 @@ impl BorrowckMode {
|
||||||
BorrowckMode::Migrate => true,
|
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 {
|
pub enum Input {
|
||||||
|
|
|
@ -1435,12 +1435,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
self.queries.on_disk_cache.serialize(self.global_tcx(), encoder)
|
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
|
/// If `true`, we should use the MIR-based borrowck, but also
|
||||||
/// fall back on the AST borrowck if the MIR-based one errors.
|
/// fall back on the AST borrowck if the MIR-based one errors.
|
||||||
pub fn migrate_borrowck(self) -> bool {
|
pub fn migrate_borrowck(self) -> bool {
|
||||||
|
|
|
@ -4,7 +4,6 @@ use crate::hir::def::{DefKind, Export};
|
||||||
use crate::hir::{self, TraitCandidate, ItemLocalId, CodegenFnAttrs};
|
use crate::hir::{self, TraitCandidate, ItemLocalId, CodegenFnAttrs};
|
||||||
use crate::infer::canonical::{self, Canonical};
|
use crate::infer::canonical::{self, Canonical};
|
||||||
use crate::lint;
|
use crate::lint;
|
||||||
use crate::middle::borrowck::BorrowCheckResult;
|
|
||||||
use crate::middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary, ForeignModule};
|
use crate::middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary, ForeignModule};
|
||||||
use crate::middle::cstore::{NativeLibraryKind, DepKind, CrateSource};
|
use crate::middle::cstore::{NativeLibraryKind, DepKind, CrateSource};
|
||||||
use crate::middle::privacy::AccessLevels;
|
use crate::middle::privacy::AccessLevels;
|
||||||
|
|
|
@ -1932,41 +1932,20 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Reservation(wk @ WriteKind::Move)
|
Reservation(WriteKind::Move)
|
||||||
| Write(wk @ WriteKind::Move)
|
| Write(WriteKind::Move)
|
||||||
| Reservation(wk @ WriteKind::StorageDeadOrDrop)
|
| Reservation(WriteKind::StorageDeadOrDrop)
|
||||||
| Reservation(wk @ WriteKind::MutableBorrow(BorrowKind::Shared))
|
| Reservation(WriteKind::MutableBorrow(BorrowKind::Shared))
|
||||||
| Reservation(wk @ WriteKind::MutableBorrow(BorrowKind::Shallow))
|
| Reservation(WriteKind::MutableBorrow(BorrowKind::Shallow))
|
||||||
| Write(wk @ WriteKind::StorageDeadOrDrop)
|
| Write(WriteKind::StorageDeadOrDrop)
|
||||||
| Write(wk @ WriteKind::MutableBorrow(BorrowKind::Shared))
|
| Write(WriteKind::MutableBorrow(BorrowKind::Shared))
|
||||||
| Write(wk @ WriteKind::MutableBorrow(BorrowKind::Shallow)) => {
|
| Write(WriteKind::MutableBorrow(BorrowKind::Shallow)) => {
|
||||||
if let (Err(place_err), true) = (
|
if let (Err(_), true) = (
|
||||||
self.is_mutable(place.as_ref(), is_local_mutation_allowed),
|
self.is_mutable(place.as_ref(), is_local_mutation_allowed),
|
||||||
self.errors_buffer.is_empty()
|
self.errors_buffer.is_empty()
|
||||||
) {
|
) {
|
||||||
if self.infcx.tcx.migrate_borrowck() {
|
// rust-lang/rust#46908: In pure NLL mode this code path should
|
||||||
// rust-lang/rust#46908: In pure NLL mode this
|
// be unreachable (and thus we signal an ICE in the else branch here).
|
||||||
// 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_bug!(
|
||||||
span,
|
span,
|
||||||
"Accessing `{:?}` with the kind `{:?}` shouldn't be possible",
|
"Accessing `{:?}` with the kind `{:?}` shouldn't be possible",
|
||||||
|
@ -1974,7 +1953,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
kind,
|
kind,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Activation(..) => {
|
Activation(..) => {
|
||||||
|
|
|
@ -28,17 +28,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateDrops {
|
||||||
let param_env = tcx.param_env(src.def_id()).with_reveal_all();
|
let param_env = tcx.param_env(src.def_id()).with_reveal_all();
|
||||||
let move_data = match MoveData::gather_moves(body, tcx) {
|
let move_data = match MoveData::gather_moves(body, tcx) {
|
||||||
Ok(move_data) => move_data,
|
Ok(move_data) => move_data,
|
||||||
Err((move_data, _move_errors)) => {
|
Err(_) => bug!("No `move_errors` should be allowed in MIR borrowck"),
|
||||||
// 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
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let elaborate_patch = {
|
let elaborate_patch = {
|
||||||
let body = &*body;
|
let body = &*body;
|
||||||
|
|
|
@ -291,10 +291,6 @@ fn optimized_mir(tcx: TyCtxt<'_>, def_id: DefId) -> &Body<'_> {
|
||||||
// execute before we can steal.
|
// execute before we can steal.
|
||||||
tcx.ensure().mir_borrowck(def_id);
|
tcx.ensure().mir_borrowck(def_id);
|
||||||
|
|
||||||
if tcx.use_ast_borrowck() {
|
|
||||||
tcx.ensure().borrowck(def_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
let (body, _) = tcx.mir_validated(def_id);
|
let (body, _) = tcx.mir_validated(def_id);
|
||||||
let mut body = body.steal();
|
let mut body = body.steal();
|
||||||
run_optimization_passes(tcx, &mut body, def_id, None);
|
run_optimization_passes(tcx, &mut body, def_id, None);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue