//! This query borrow-checks the MIR to (further) ensure it is not broken.
-use rustc::infer::InferCtxt;
use rustc::lint::builtin::MUTABLE_BORROW_RESERVATION_CONFLICT;
use rustc::lint::builtin::UNUSED_MUT;
use rustc::mir::{
use rustc_hir::{def_id::DefId, HirId, Node};
use rustc_index::bit_set::BitSet;
use rustc_index::vec::IndexVec;
+use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
use either::Either;
use smallvec::SmallVec;
*providers = Providers { mir_borrowck, ..*providers };
}
-fn mir_borrowck(tcx: TyCtxt<'_>, def_id: DefId) -> BorrowCheckResult<'_> {
+fn mir_borrowck(tcx: TyCtxt<'_>, def_id: DefId) -> &BorrowCheckResult<'_> {
let (input_body, promoted) = tcx.mir_validated(def_id);
debug!("run query mir_borrowck: {}", tcx.def_path_str(def_id));
});
debug!("mir_borrowck done");
- opt_closure_req
+ tcx.arena.alloc(opt_closure_req)
}
fn do_mir_borrowck<'a, 'tcx>(
// Gather the upvars of a closure, if any.
let tables = tcx.typeck_tables_of(def_id);
+ if tables.tainted_by_errors {
+ infcx.set_tainted_by_errors();
+ }
let upvars: Vec<_> = tables
.upvar_list
.get(&def_id)
Rc::new(BorrowSet::build(tcx, body, locals_are_invalidated_at_exit, &mdpe.move_data));
// Compute non-lexical lifetimes.
- let nll::NllOutput { regioncx, polonius_output, opt_closure_req, nll_errors } =
- nll::compute_regions(
- infcx,
- def_id,
- free_regions,
- body,
- &promoted,
- location_table,
- param_env,
- &mut flow_inits,
- &mdpe.move_data,
- &borrow_set,
- );
+ let nll::NllOutput {
+ regioncx,
+ opaque_type_values,
+ polonius_output,
+ opt_closure_req,
+ nll_errors,
+ } = nll::compute_regions(
+ infcx,
+ def_id,
+ free_regions,
+ body,
+ &promoted,
+ location_table,
+ param_env,
+ &mut flow_inits,
+ &mdpe.move_data,
+ &borrow_set,
+ );
// Dump MIR results into a file, if that is enabled. This let us
// write unit-tests, as well as helping with debugging.
nll::dump_mir_results(infcx, MirSource::item(def_id), &body, ®ioncx, &opt_closure_req);
- // We also have a `#[rustc_nll]` annotation that causes us to dump
+ // We also have a `#[rustc_regions]` annotation that causes us to dump
// information.
- nll::dump_annotation(infcx, &body, def_id, ®ioncx, &opt_closure_req, &mut errors_buffer);
+ nll::dump_annotation(
+ infcx,
+ &body,
+ def_id,
+ ®ioncx,
+ &opt_closure_req,
+ &opaque_type_values,
+ &mut errors_buffer,
+ );
// The various `flow_*` structures can be large. We drop `flow_inits` here
// so it doesn't overlap with the others below. This reduces peak memory
// Skip over locals that begin with an underscore or have no name
match mbcx.local_names[local] {
Some(name) => {
- if name.as_str().starts_with("_") {
+ if name.as_str().starts_with('_') {
continue;
}
}
}
let result = BorrowCheckResult {
+ concrete_opaque_types: opaque_type_values,
closure_requirements: opt_closure_req,
used_mut_upvars: mbcx.used_mut_upvars,
};
) {
if let Some(mpi) = self.move_path_for_place(place_span.0) {
let move_paths = &self.move_data.move_paths;
- let mut child = move_paths[mpi].first_child;
- while let Some(child_mpi) = child {
- let child_move_path = &move_paths[child_mpi];
+
+ let root_path = &move_paths[mpi];
+ for (child_mpi, child_move_path) in root_path.children(move_paths) {
let last_proj = child_move_path.place.projection.last().unwrap();
if let ProjectionElem::ConstantIndex { offset, from_end, .. } = last_proj {
debug_assert!(!from_end, "Array constant indexing shouldn't be `from_end`.");
}
}
}
- child = child_move_path.next_sibling;
}
}
}