Do not run AST borrowck when -Zborrowck=mir
This commit is contained in:
parent
0e31e2fa9b
commit
25266c1840
@ -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 {
|
||||
|
@ -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();
|
||||
|
@ -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",
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user