Skip to content

Commit

Permalink
Auto merge of rust-lang#64790 - Centril:rip-ast-borrowck, r=matthewja…
Browse files Browse the repository at this point in the history
…sper

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 rust-lang#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 (rust-lang#59159).

r? @matthewjasper

------------------------

![ast-borrowck-rip](https://user-images.githubusercontent.com/855702/65646791-91a87600-dffc-11e9-9814-deed6b821c80.png)
  • Loading branch information
bors committed Sep 27, 2019
2 parents 084beb8 + 001357f commit c6f87c2
Show file tree
Hide file tree
Showing 36 changed files with 49 additions and 6,019 deletions.
13 changes: 0 additions & 13 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3337,17 +3337,6 @@ dependencies = [
"core",
]

[[package]]
name = "rustc_ast_borrowck"
version = "0.0.0"
dependencies = [
"graphviz",
"log",
"rustc",
"rustc_data_structures",
"syntax_pos",
]

[[package]]
name = "rustc_codegen_llvm"
version = "0.0.0"
Expand Down Expand Up @@ -3425,7 +3414,6 @@ dependencies = [
"lazy_static 1.3.0",
"log",
"rustc",
"rustc_ast_borrowck",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_errors",
Expand Down Expand Up @@ -3483,7 +3471,6 @@ dependencies = [
"once_cell",
"rustc",
"rustc-rayon",
"rustc_ast_borrowck",
"rustc_codegen_ssa",
"rustc_codegen_utils",
"rustc_data_structures",
Expand Down
1 change: 0 additions & 1 deletion src/librustc/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down
11 changes: 0 additions & 11 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1291,17 +1291,6 @@ pub struct Arm {
pub body: P<Expr>,
}

impl Arm {
// HACK(or_patterns; Centril | dlrobertson): Remove this and
// correctly handle each case in which this method is used.
pub fn top_pats_hack(&self) -> &[P<Pat>] {
match &self.pat.kind {
PatKind::Or(pats) => pats,
_ => std::slice::from_ref(&self.pat),
}
}
}

#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
pub enum Guard {
If(P<Expr>),
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
1 change: 0 additions & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
31 changes: 0 additions & 31 deletions src/librustc/middle/borrowck.rs

This file was deleted.

6 changes: 1 addition & 5 deletions src/librustc/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -469,7 +465,7 @@ rustc_queries! {
}

TypeChecking {
query check_match(key: DefId) -> SignalledError {
query check_match(key: DefId) {
cache_on_disk_if { key.is_local() }
}

Expand Down
18 changes: 0 additions & 18 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -1268,14 +1260,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
save_analysis: bool = (false, parse_bool, [UNTRACKED],
"write syntax and type analysis (in JSON format) information, in \
addition to normal output"),
flowgraph_print_loans: bool = (false, parse_bool, [UNTRACKED],
"include loan analysis data in -Z unpretty flowgraph output"),
flowgraph_print_moves: bool = (false, parse_bool, [UNTRACKED],
"include move analysis data in -Z unpretty flowgraph output"),
flowgraph_print_assigns: bool = (false, parse_bool, [UNTRACKED],
"include assignment analysis data in -Z unpretty flowgraph output"),
flowgraph_print_all: bool = (false, parse_bool, [UNTRACKED],
"include all dataflow analysis data in -Z unpretty flowgraph output"),
print_region_graph: bool = (false, parse_bool, [UNTRACKED],
"prints region inference graph. \
Use with RUST_REGION_GRAPH=help for more info"),
Expand Down Expand Up @@ -1424,8 +1408,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
valid types are any of the types for `--pretty`, as well as:
`expanded`, `expanded,identified`,
`expanded,hygiene` (with internal representations),
`flowgraph=<nodeid>` (graphviz formatted flowgraph for node),
`flowgraph,unlabelled=<nodeid>` (unlabelled graphviz formatted flowgraph for node),
`everybody_loops` (all function bodies replaced with `loop {}`),
`hir` (the HIR), `hir,identified`,
`hir,typed` (HIR with types for each node),
Expand Down
8 changes: 0 additions & 8 deletions src/librustc/session/config/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,14 +589,6 @@ fn test_debugging_options_tracking_hash() {
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
opts.debugging_opts.save_analysis = true;
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
opts.debugging_opts.flowgraph_print_loans = true;
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
opts.debugging_opts.flowgraph_print_moves = true;
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
opts.debugging_opts.flowgraph_print_assigns = true;
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
opts.debugging_opts.flowgraph_print_all = true;
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
opts.debugging_opts.print_region_graph = true;
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
opts.debugging_opts.parse_only = true;
Expand Down
6 changes: 0 additions & 6 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion src/librustc/ty/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, SignalledError};
use crate::middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary, ForeignModule};
use crate::middle::cstore::{NativeLibraryKind, DepKind, CrateSource};
use crate::middle::privacy::AccessLevels;
Expand Down
20 changes: 0 additions & 20 deletions src/librustc_ast_borrowck/Cargo.toml

This file was deleted.

Loading

0 comments on commit c6f87c2

Please sign in to comment.