Skip to content

Commit c6f87c2

Browse files
committed
Auto merge of #64790 - Centril:rip-ast-borrowck, r=matthewjasper
Rest In Peace, AST borrowck (2012-2019) After having served us for 7 years, the AST borrow-checker is no more. This PR starts from the commit `rm -rf librustc_ast_borrowck`, building on #64221, and is probably best read commit by commit. Migrate mode is not removed yet as it may be useful for NLL => polonius and it is also used for the `mutable_borrow_reservation_conflict` issue (#59159). r? @matthewjasper ------------------------ ![ast-borrowck-rip](https://user-images.githubusercontent.com/855702/65646791-91a87600-dffc-11e9-9814-deed6b821c80.png)
2 parents 084beb8 + 001357f commit c6f87c2

36 files changed

+49
-6019
lines changed

Cargo.lock

-13
Original file line numberDiff line numberDiff line change
@@ -3337,17 +3337,6 @@ dependencies = [
33373337
"core",
33383338
]
33393339

3340-
[[package]]
3341-
name = "rustc_ast_borrowck"
3342-
version = "0.0.0"
3343-
dependencies = [
3344-
"graphviz",
3345-
"log",
3346-
"rustc",
3347-
"rustc_data_structures",
3348-
"syntax_pos",
3349-
]
3350-
33513340
[[package]]
33523341
name = "rustc_codegen_llvm"
33533342
version = "0.0.0"
@@ -3425,7 +3414,6 @@ dependencies = [
34253414
"lazy_static 1.3.0",
34263415
"log",
34273416
"rustc",
3428-
"rustc_ast_borrowck",
34293417
"rustc_codegen_utils",
34303418
"rustc_data_structures",
34313419
"rustc_errors",
@@ -3483,7 +3471,6 @@ dependencies = [
34833471
"once_cell",
34843472
"rustc",
34853473
"rustc-rayon",
3486-
"rustc_ast_borrowck",
34873474
"rustc_codegen_ssa",
34883475
"rustc_codegen_utils",
34893476
"rustc_data_structures",

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/hir/mod.rs

-11
Original file line numberDiff line numberDiff line change
@@ -1291,17 +1291,6 @@ pub struct Arm {
12911291
pub body: P<Expr>,
12921292
}
12931293

1294-
impl Arm {
1295-
// HACK(or_patterns; Centril | dlrobertson): Remove this and
1296-
// correctly handle each case in which this method is used.
1297-
pub fn top_pats_hack(&self) -> &[P<Pat>] {
1298-
match &self.pat.kind {
1299-
PatKind::Or(pats) => pats,
1300-
_ => std::slice::from_ref(&self.pat),
1301-
}
1302-
}
1303-
}
1304-
13051294
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
13061295
pub enum Guard {
13071296
If(P<Expr>),

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

+1-5
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> {
@@ -469,7 +465,7 @@ rustc_queries! {
469465
}
470466

471467
TypeChecking {
472-
query check_match(key: DefId) -> SignalledError {
468+
query check_match(key: DefId) {
473469
cache_on_disk_if { key.is_local() }
474470
}
475471

src/librustc/session/config.rs

-18
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 {
@@ -1268,14 +1260,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
12681260
save_analysis: bool = (false, parse_bool, [UNTRACKED],
12691261
"write syntax and type analysis (in JSON format) information, in \
12701262
addition to normal output"),
1271-
flowgraph_print_loans: bool = (false, parse_bool, [UNTRACKED],
1272-
"include loan analysis data in -Z unpretty flowgraph output"),
1273-
flowgraph_print_moves: bool = (false, parse_bool, [UNTRACKED],
1274-
"include move analysis data in -Z unpretty flowgraph output"),
1275-
flowgraph_print_assigns: bool = (false, parse_bool, [UNTRACKED],
1276-
"include assignment analysis data in -Z unpretty flowgraph output"),
1277-
flowgraph_print_all: bool = (false, parse_bool, [UNTRACKED],
1278-
"include all dataflow analysis data in -Z unpretty flowgraph output"),
12791263
print_region_graph: bool = (false, parse_bool, [UNTRACKED],
12801264
"prints region inference graph. \
12811265
Use with RUST_REGION_GRAPH=help for more info"),
@@ -1424,8 +1408,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
14241408
valid types are any of the types for `--pretty`, as well as:
14251409
`expanded`, `expanded,identified`,
14261410
`expanded,hygiene` (with internal representations),
1427-
`flowgraph=<nodeid>` (graphviz formatted flowgraph for node),
1428-
`flowgraph,unlabelled=<nodeid>` (unlabelled graphviz formatted flowgraph for node),
14291411
`everybody_loops` (all function bodies replaced with `loop {}`),
14301412
`hir` (the HIR), `hir,identified`,
14311413
`hir,typed` (HIR with types for each node),

src/librustc/session/config/tests.rs

-8
Original file line numberDiff line numberDiff line change
@@ -589,14 +589,6 @@ fn test_debugging_options_tracking_hash() {
589589
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
590590
opts.debugging_opts.save_analysis = true;
591591
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
592-
opts.debugging_opts.flowgraph_print_loans = true;
593-
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
594-
opts.debugging_opts.flowgraph_print_moves = true;
595-
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
596-
opts.debugging_opts.flowgraph_print_assigns = true;
597-
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
598-
opts.debugging_opts.flowgraph_print_all = true;
599-
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
600592
opts.debugging_opts.print_region_graph = true;
601593
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
602594
opts.debugging_opts.parse_only = true;

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, SignalledError};
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_ast_borrowck/Cargo.toml

-20
This file was deleted.

0 commit comments

Comments
 (0)