Merge remote-tracking branch 'origin/master' into gen
This commit is contained in:
commit
5dc9d71521
@ -411,6 +411,8 @@ pub fn to_dep_node(self, tcx: TyCtxt, kind: DepKind) -> DepNode {
|
||||
|
||||
[] BorrowCheckKrate,
|
||||
[] BorrowCheck(DefId),
|
||||
[] MirBorrowCheck(DefId),
|
||||
|
||||
[] RvalueCheck(DefId),
|
||||
[] Reachability,
|
||||
[] MirKeys,
|
||||
|
@ -934,6 +934,8 @@ fn default() -> Self {
|
||||
[] coherent_trait: coherent_trait_dep_node((CrateNum, DefId)) -> (),
|
||||
|
||||
[] borrowck: BorrowCheck(DefId) -> (),
|
||||
// FIXME: shouldn't this return a `Result<(), BorrowckErrors>` instead?
|
||||
[] mir_borrowck: MirBorrowCheck(DefId) -> (),
|
||||
|
||||
/// Gets a complete map from all types to their inherent impls.
|
||||
/// Not meant to be used directly outside of coherence.
|
||||
|
@ -983,10 +983,6 @@ macro_rules! try_with_f {
|
||||
|
||||
// borrowck runs between MIR_VALIDATED and MIR_OPTIMIZED.
|
||||
|
||||
// FIXME: niko says this should be a query (see rustc::ty::maps)
|
||||
// instead of a pass.
|
||||
passes.push_pass(MIR_VALIDATED, mir::transform::borrow_check::BorrowckMir);
|
||||
|
||||
// These next passes must be executed together
|
||||
passes.push_pass(MIR_OPTIMIZED, mir::transform::no_landing_pads::NoLandingPads);
|
||||
passes.push_pass(MIR_OPTIMIZED, mir::transform::add_call_guards::CriticalCallEdges);
|
||||
@ -1077,6 +1073,10 @@ macro_rules! try_with_f {
|
||||
"borrow checking",
|
||||
|| borrowck::check_crate(tcx));
|
||||
|
||||
time(time_passes,
|
||||
"MIR borrow checking",
|
||||
|| for def_id in tcx.body_owners() { tcx.mir_borrowck(def_id) });
|
||||
|
||||
// Avoid overwhelming user with errors if type checking failed.
|
||||
// I'm not sure how helpful this is, to be honest, but it avoids
|
||||
// a
|
||||
|
@ -8,14 +8,16 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//! This pass borrow-checks the MIR to (further) ensure it is not broken.
|
||||
//! This query borrow-checks the MIR to (further) ensure it is not broken.
|
||||
|
||||
use rustc::hir::def_id::{DefId};
|
||||
use rustc::infer::{InferCtxt};
|
||||
use rustc::ty::{self, TyCtxt, ParamEnv};
|
||||
use rustc::ty::maps::Providers;
|
||||
use rustc::mir::{AssertMessage, BasicBlock, BorrowKind, Location, Lvalue};
|
||||
use rustc::mir::{Mir, Mutability, Operand, Projection, ProjectionElem, Rvalue};
|
||||
use rustc::mir::{Statement, StatementKind, Terminator, TerminatorKind};
|
||||
use rustc::mir::transform::{MirPass, MirSource};
|
||||
use rustc::mir::transform::{MirSource};
|
||||
|
||||
use rustc_data_structures::indexed_set::{self, IdxSetBuf};
|
||||
use rustc_data_structures::indexed_vec::{Idx};
|
||||
@ -34,35 +36,25 @@
|
||||
use self::MutateMode::{JustWrite, WriteAndRead};
|
||||
use self::ConsumeKind::{Consume};
|
||||
|
||||
pub struct BorrowckMir;
|
||||
|
||||
impl MirPass for BorrowckMir {
|
||||
fn run_pass<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, src: MirSource, mir: &mut Mir<'tcx>) {
|
||||
|
||||
// let err_count = tcx.sess.err_count();
|
||||
// if err_count > 0 {
|
||||
// // compiling a broken program can obviously result in a
|
||||
// // broken MIR, so try not to report duplicate errors.
|
||||
// debug!("skipping BorrowckMir: {} due to {} previous errors",
|
||||
// tcx.node_path_str(src.item_id()), err_count);
|
||||
// return;
|
||||
// }
|
||||
|
||||
debug!("run_pass BorrowckMir: {}", tcx.node_path_str(src.item_id()));
|
||||
|
||||
let def_id = tcx.hir.local_def_id(src.item_id());
|
||||
if tcx.has_attr(def_id, "rustc_mir_borrowck") || tcx.sess.opts.debugging_opts.borrowck_mir {
|
||||
borrowck_mir(tcx, src, mir);
|
||||
}
|
||||
}
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
*providers = Providers {
|
||||
mir_borrowck,
|
||||
..*providers
|
||||
};
|
||||
}
|
||||
|
||||
fn borrowck_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, src: MirSource, mir: &Mir<'tcx>)
|
||||
{
|
||||
let id = src.item_id();
|
||||
let def_id = tcx.hir.local_def_id(id);
|
||||
debug!("borrowck_mir({}) UNIMPLEMENTED", tcx.item_path_str(def_id));
|
||||
fn mir_borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
|
||||
let mir = tcx.mir_validated(def_id);
|
||||
let src = MirSource::from_local_def_id(tcx, def_id);
|
||||
debug!("run query mir_borrowck: {}", tcx.node_path_str(src.item_id()));
|
||||
|
||||
let mir: &Mir<'tcx> = &mir.borrow();
|
||||
if !tcx.has_attr(def_id, "rustc_mir_borrowck") || !tcx.sess.opts.debugging_opts.borrowck_mir {
|
||||
return;
|
||||
}
|
||||
|
||||
let id = src.item_id();
|
||||
let attributes = tcx.get_attrs(def_id);
|
||||
let param_env = tcx.param_env(def_id);
|
||||
tcx.infer_ctxt().enter(|_infcx| {
|
||||
@ -96,7 +88,7 @@ fn borrowck_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, src: MirSource, mir: &Mir
|
||||
mbcx.analyze_results(&mut state); // entry point for DataflowResultsConsumer
|
||||
});
|
||||
|
||||
debug!("borrowck_mir done");
|
||||
debug!("mir_borrowck done");
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
@ -45,6 +45,7 @@
|
||||
|
||||
mod diagnostics;
|
||||
|
||||
mod borrow_check;
|
||||
mod build;
|
||||
mod dataflow;
|
||||
mod hair;
|
||||
@ -55,6 +56,7 @@
|
||||
use rustc::ty::maps::Providers;
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
borrow_check::provide(providers);
|
||||
shim::provide(providers);
|
||||
transform::provide(providers);
|
||||
}
|
||||
|
@ -31,7 +31,6 @@
|
||||
pub mod erase_regions;
|
||||
pub mod no_landing_pads;
|
||||
pub mod type_check;
|
||||
pub mod borrow_check;
|
||||
pub mod rustc_peek;
|
||||
pub mod elaborate_drops;
|
||||
pub mod add_call_guards;
|
||||
@ -124,8 +123,9 @@ fn mir_validated<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx
|
||||
}
|
||||
|
||||
fn optimized_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx Mir<'tcx> {
|
||||
// Borrowck uses `mir_validated`, so we have to force it to
|
||||
// (Mir-)Borrowck uses `mir_validated`, so we have to force it to
|
||||
// execute before we can steal.
|
||||
ty::queries::mir_borrowck::force(tcx, DUMMY_SP, def_id);
|
||||
ty::queries::borrowck::force(tcx, DUMMY_SP, def_id);
|
||||
|
||||
let mut mir = tcx.mir_validated(def_id).steal();
|
||||
|
Loading…
Reference in New Issue
Block a user