Skip to content

Commit dfd365f

Browse files
committed
cleanup dead ast-borrowck / migrate-mode code.
1 parent defd508 commit dfd365f

File tree

11 files changed

+20
-106
lines changed

11 files changed

+20
-106
lines changed

src/librustc/arena.rs

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ macro_rules! arena_types {
8686
rustc::infer::canonical::QueryResponse<'tcx, rustc::ty::Ty<'tcx>>
8787
>,
8888
[few] crate_inherent_impls: rustc::ty::CrateInherentImpls,
89-
[decode] borrowck: rustc::middle::borrowck::BorrowCheckResult,
9089
[few] upstream_monomorphizations:
9190
rustc::util::nodemap::DefIdMap<
9291
rustc_data_structures::fx::FxHashMap<

src/librustc/infer/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ impl SuppressRegionErrors {
9393
/// checks, so we should ignore errors if NLL is (unconditionally)
9494
/// enabled.
9595
pub fn when_nll_is_enabled(tcx: TyCtxt<'_>) -> Self {
96+
// FIXME(Centril): Once we actually remove `::Migrate` also make
97+
// this always `true` and then proceed to eliminate the dead code.
9698
match tcx.borrowck_mode() {
9799
// If we're on Migrate mode, report AST region errors
98100
BorrowckMode::Migrate => SuppressRegionErrors { suppressed: false },

src/librustc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ pub mod infer;
100100
pub mod lint;
101101

102102
pub mod middle {
103-
pub mod borrowck;
104103
pub mod expr_use_visitor;
105104
pub mod cstore;
106105
pub mod dead;

src/librustc/middle/borrowck.rs

-31
This file was deleted.

src/librustc/query/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,6 @@ rustc_queries! {
397397
}
398398

399399
BorrowChecking {
400-
query borrowck(key: DefId) -> &'tcx BorrowCheckResult {
401-
cache_on_disk_if { key.is_local() }
402-
}
403-
404400
/// Borrow-checks the function body. If this is a closure, returns
405401
/// additional requirements that the closure's creator must verify.
406402
query mir_borrowck(key: DefId) -> mir::BorrowCheckResult<'tcx> {

src/librustc/session/config.rs

-8
Original file line numberDiff line numberDiff line change
@@ -478,14 +478,6 @@ impl BorrowckMode {
478478
BorrowckMode::Migrate => true,
479479
}
480480
}
481-
482-
/// Returns whether we should emit the AST-based borrow checker errors.
483-
pub fn use_ast(self) -> bool {
484-
match self {
485-
BorrowckMode::Mir => false,
486-
BorrowckMode::Migrate => false,
487-
}
488-
}
489481
}
490482

491483
pub enum Input {

src/librustc/ty/context.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1435,12 +1435,6 @@ impl<'tcx> TyCtxt<'tcx> {
14351435
self.queries.on_disk_cache.serialize(self.global_tcx(), encoder)
14361436
}
14371437

1438-
/// If `true`, we should use the AST-based borrowck (we may *also* use
1439-
/// the MIR-based borrowck).
1440-
pub fn use_ast_borrowck(self) -> bool {
1441-
self.borrowck_mode().use_ast()
1442-
}
1443-
14441438
/// If `true`, we should use the MIR-based borrowck, but also
14451439
/// fall back on the AST borrowck if the MIR-based one errors.
14461440
pub fn migrate_borrowck(self) -> bool {

src/librustc/ty/query/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::hir::def::{DefKind, Export};
44
use crate::hir::{self, TraitCandidate, ItemLocalId, CodegenFnAttrs};
55
use crate::infer::canonical::{self, Canonical};
66
use crate::lint;
7-
use crate::middle::borrowck::BorrowCheckResult;
87
use crate::middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary, ForeignModule};
98
use crate::middle::cstore::{NativeLibraryKind, DepKind, CrateSource};
109
use crate::middle::privacy::AccessLevels;

src/librustc_mir/borrow_check/mod.rs

+17-39
Original file line numberDiff line numberDiff line change
@@ -1932,48 +1932,26 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
19321932
}
19331933
}
19341934

1935-
Reservation(wk @ WriteKind::Move)
1936-
| Write(wk @ WriteKind::Move)
1937-
| Reservation(wk @ WriteKind::StorageDeadOrDrop)
1938-
| Reservation(wk @ WriteKind::MutableBorrow(BorrowKind::Shared))
1939-
| Reservation(wk @ WriteKind::MutableBorrow(BorrowKind::Shallow))
1940-
| Write(wk @ WriteKind::StorageDeadOrDrop)
1941-
| Write(wk @ WriteKind::MutableBorrow(BorrowKind::Shared))
1942-
| Write(wk @ WriteKind::MutableBorrow(BorrowKind::Shallow)) => {
1943-
if let (Err(place_err), true) = (
1935+
Reservation(WriteKind::Move)
1936+
| Write(WriteKind::Move)
1937+
| Reservation(WriteKind::StorageDeadOrDrop)
1938+
| Reservation(WriteKind::MutableBorrow(BorrowKind::Shared))
1939+
| Reservation(WriteKind::MutableBorrow(BorrowKind::Shallow))
1940+
| Write(WriteKind::StorageDeadOrDrop)
1941+
| Write(WriteKind::MutableBorrow(BorrowKind::Shared))
1942+
| Write(WriteKind::MutableBorrow(BorrowKind::Shallow)) => {
1943+
if let (Err(_), true) = (
19441944
self.is_mutable(place.as_ref(), is_local_mutation_allowed),
19451945
self.errors_buffer.is_empty()
19461946
) {
1947-
if self.infcx.tcx.migrate_borrowck() {
1948-
// rust-lang/rust#46908: In pure NLL mode this
1949-
// code path should be unreachable (and thus
1950-
// we signal an ICE in the else branch
1951-
// here). But we can legitimately get here
1952-
// under borrowck=migrate mode, so instead of
1953-
// ICE'ing we instead report a legitimate
1954-
// error (which will then be downgraded to a
1955-
// warning by the migrate machinery).
1956-
error_access = match wk {
1957-
WriteKind::MutableBorrow(_) => AccessKind::MutableBorrow,
1958-
WriteKind::Move => AccessKind::Move,
1959-
WriteKind::StorageDeadOrDrop |
1960-
WriteKind::Mutate => AccessKind::Mutate,
1961-
};
1962-
self.report_mutability_error(
1963-
place,
1964-
span,
1965-
place_err,
1966-
error_access,
1967-
location,
1968-
);
1969-
} else {
1970-
span_bug!(
1971-
span,
1972-
"Accessing `{:?}` with the kind `{:?}` shouldn't be possible",
1973-
place,
1974-
kind,
1975-
);
1976-
}
1947+
// rust-lang/rust#46908: In pure NLL mode this code path should
1948+
// be unreachable (and thus we signal an ICE in the else branch here).
1949+
span_bug!(
1950+
span,
1951+
"Accessing `{:?}` with the kind `{:?}` shouldn't be possible",
1952+
place,
1953+
kind,
1954+
);
19771955
}
19781956
return false;
19791957
}

src/librustc_mir/transform/elaborate_drops.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateDrops {
2828
let param_env = tcx.param_env(src.def_id()).with_reveal_all();
2929
let move_data = match MoveData::gather_moves(body, tcx) {
3030
Ok(move_data) => move_data,
31-
Err((move_data, _move_errors)) => {
32-
// The only way we should be allowing any move_errors
33-
// in here is if we are in the migration path for the
34-
// NLL-based MIR-borrowck.
35-
//
36-
// If we are in the migration path, we have already
37-
// reported these errors as warnings to the user. So
38-
// we will just ignore them here.
39-
assert!(tcx.migrate_borrowck());
40-
move_data
41-
}
31+
Err(_) => bug!("No `move_errors` should be allowed in MIR borrowck"),
4232
};
4333
let elaborate_patch = {
4434
let body = &*body;

src/librustc_mir/transform/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,6 @@ fn optimized_mir(tcx: TyCtxt<'_>, def_id: DefId) -> &Body<'_> {
291291
// execute before we can steal.
292292
tcx.ensure().mir_borrowck(def_id);
293293

294-
if tcx.use_ast_borrowck() {
295-
tcx.ensure().borrowck(def_id);
296-
}
297-
298294
let (body, _) = tcx.mir_validated(def_id);
299295
let mut body = body.steal();
300296
run_optimization_passes(tcx, &mut body, def_id, None);

0 commit comments

Comments
 (0)