diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2018-07-05 15:14:34 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2018-07-05 16:57:32 -0300 |
| commit | 25266c18409858ac0c482bc00a6d72c0f83f3df2 (patch) | |
| tree | 1be792a758064b6a0538dd1d6c55e6c6c1d30e27 /src | |
| parent | 0e31e2fa9b984ac15e3818685fa3ad87216811df (diff) | |
| download | rust-25266c18409858ac0c482bc00a6d72c0f83f3df2.tar.gz rust-25266c18409858ac0c482bc00a6d72c0f83f3df2.zip | |
Do not run AST borrowck when -Zborrowck=mir
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/ty/context.rs | 6 | ||||
| -rw-r--r-- | src/librustc_borrowck/borrowck/mod.rs | 2 | ||||
| -rw-r--r-- | src/librustc_driver/driver.rs | 6 | ||||
| -rw-r--r-- | src/librustc_mir/transform/mod.rs | 5 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0017.nll.stderr | 12 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0388.nll.stderr | 12 |
6 files changed, 29 insertions, 14 deletions
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 5142a30ae57..8f7f9d09423 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1354,6 +1354,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { !self.sess.opts.debugging_opts.disable_ast_check_for_mutation_in_guard } + /// 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 (we may *also* use /// the AST-based borrowck). pub fn use_mir_borrowck(self) -> bool { diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 4bd8e6afa76..df1b1138f3e 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -89,6 +89,8 @@ pub struct AnalysisData<'a, 'tcx: 'a> { fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId) -> Lrc<BorrowCheckResult> { + assert!(tcx.use_ast_borrowck()); + debug!("borrowck(body_owner_def_id={:?})", owner_def_id); let owner_id = tcx.hir.as_local_node_id(owner_def_id).unwrap(); diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index feeac9d938b..96e9616699d 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -1279,7 +1279,11 @@ where middle::liveness::check_crate(tcx) }); - time(sess, "borrow checking", || borrowck::check_crate(tcx)); + time(sess, "borrow checking", || { + if tcx.use_ast_borrowck() { + borrowck::check_crate(tcx); + } + }); time(sess, "MIR borrow checking", diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index 06be2bb3734..90dfebeef1b 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -225,7 +225,10 @@ fn optimized_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx // (Mir-)Borrowck uses `mir_validated`, so we have to force it to // execute before we can steal. let _ = tcx.mir_borrowck(def_id); - let _ = tcx.borrowck(def_id); + + if tcx.use_ast_borrowck() { + let _ = tcx.borrowck(def_id); + } let mut mir = tcx.mir_validated(def_id).steal(); run_passes![tcx, mir, def_id, 2; diff --git a/src/test/ui/error-codes/E0017.nll.stderr b/src/test/ui/error-codes/E0017.nll.stderr index ec31f5d05d7..addbbf4434f 100644 --- a/src/test/ui/error-codes/E0017.nll.stderr +++ b/src/test/ui/error-codes/E0017.nll.stderr @@ -10,18 +10,18 @@ error[E0017]: references in statics may only refer to immutable values LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 | ^^^^^^ statics require immutable values -error[E0017]: references in statics may only refer to immutable values - --> $DIR/E0017.rs:17:38 - | -LL | static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017 - | ^^^^^^ statics require immutable values - error[E0596]: cannot borrow immutable item `X` as mutable --> $DIR/E0017.rs:15:39 | LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 | ^^^^^^ cannot borrow as mutable +error[E0017]: references in statics may only refer to immutable values + --> $DIR/E0017.rs:17:38 + | +LL | static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017 + | ^^^^^^ statics require immutable values + error: aborting due to 4 previous errors Some errors occurred: E0017, E0596. diff --git a/src/test/ui/error-codes/E0388.nll.stderr b/src/test/ui/error-codes/E0388.nll.stderr index 6a4bd6b31a1..0238ca6b623 100644 --- a/src/test/ui/error-codes/E0388.nll.stderr +++ b/src/test/ui/error-codes/E0388.nll.stderr @@ -10,18 +10,18 @@ error[E0017]: references in statics may only refer to immutable values LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 | ^^^^^^ statics require immutable values -error[E0017]: references in statics may only refer to immutable values - --> $DIR/E0388.rs:17:38 - | -LL | static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017 - | ^^^^^^ statics require immutable values - error[E0596]: cannot borrow immutable item `X` as mutable --> $DIR/E0388.rs:15:39 | LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 | ^^^^^^ cannot borrow as mutable +error[E0017]: references in statics may only refer to immutable values + --> $DIR/E0388.rs:17:38 + | +LL | static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017 + | ^^^^^^ statics require immutable values + error: aborting due to 4 previous errors Some errors occurred: E0017, E0596. |
