1
Fork 0

Remove BodyCache.body and rely on Deref as much as possible for ReadOnlyBodyCache

This commit is contained in:
Paul Daniel Faria 2019-11-06 00:04:53 -05:00
parent c42bdb8c74
commit 595d161d36
30 changed files with 89 additions and 87 deletions

View file

@ -2,7 +2,7 @@ use rustc_index::vec::IndexVec;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_serialize::{Encodable, Encoder, Decodable, Decoder};
use crate::ich::StableHashingContext;
use crate::mir::{BasicBlock, BasicBlockData, Body, LocalDecls, Location, Successors};
use crate::mir::{BasicBlock, BasicBlockData, Body, HasLocalDecls, LocalDecls, Location, Successors};
use rustc_data_structures::graph::{self, GraphPredecessors, GraphSuccessors};
use rustc_data_structures::graph::dominators::{dominators, Dominators};
use std::iter;
@ -181,14 +181,6 @@ impl BodyCache<'tcx> {
ReadOnlyBodyCache::new(&self.cache, &self.body)
}
pub fn body(&self) -> &Body<'tcx> {
&self.body
}
pub fn body_mut(&mut self) -> &mut Body<'tcx> {
&mut self.body
}
pub fn cache(&self) -> &Cache { &self.cache }
pub fn basic_blocks_mut(&mut self) -> &mut IndexVec<BasicBlock, BasicBlockData<'tcx>> {
@ -231,6 +223,12 @@ impl<'tcx> DerefMut for BodyCache<'tcx> {
}
}
impl<'tcx> HasLocalDecls<'tcx> for BodyCache<'tcx> {
fn local_decls(&self) -> &LocalDecls<'tcx> {
&self.body.local_decls
}
}
#[derive(Copy, Clone, Debug)]
pub struct ReadOnlyBodyCache<'a, 'tcx> {
cache: &'a Cache,
@ -349,6 +347,12 @@ impl Index<BasicBlock> for ReadOnlyBodyCache<'a, 'tcx> {
}
}
impl<'a, 'tcx> HasLocalDecls<'tcx> for ReadOnlyBodyCache<'a, 'tcx> {
fn local_decls(&self) -> &LocalDecls<'tcx> {
&self.body.local_decls
}
}
CloneTypeFoldableAndLiftImpls! {
Cache,
}

View file

@ -254,14 +254,10 @@ macro_rules! make_mir_visitor {
fn super_body(
&mut self,
body_cache: body_cache_type!($($mutability)? '_, 'tcx)
$($mutability)? body_cache: body_cache_type!($($mutability)? '_, 'tcx)
) {
macro_rules! body {
(mut) => (body_cache.body_mut());
() => (body_cache.body());
}
let span = body_cache.body().span;
if let Some(yield_ty) = &$($mutability)? body!($($mutability)?).yield_ty {
let span = body_cache.span;
if let Some(yield_ty) = &$($mutability)? body_cache.yield_ty {
self.visit_ty(yield_ty, TyContext::YieldTy(SourceInfo {
span,
scope: OUTERMOST_SOURCE_SCOPE,
@ -279,7 +275,7 @@ macro_rules! make_mir_visitor {
self.visit_basic_block_data(bb, data);
}
let body = body!($($mutability)?);
let body: & $($mutability)? Body<'_> = & $($mutability)? body_cache;
for scope in &$($mutability)? body.source_scopes {
self.visit_source_scope_data(scope);
}

View file

@ -3023,7 +3023,7 @@ impl<'tcx> TyCtxt<'tcx> {
}
pub fn generator_layout(self, def_id: DefId) -> &'tcx GeneratorLayout<'tcx> {
self.optimized_mir(def_id).body().generator_layout.as_ref().unwrap()
self.optimized_mir(def_id).generator_layout.as_ref().unwrap()
}
/// Given the `DefId` of an impl, returns the `DefId` of the trait it implements.

View file

@ -131,7 +131,7 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
};
if is_consume {
let base_ty =
mir::Place::ty_from(place_ref.base, proj_base, self.fx.mir.body(), cx.tcx());
mir::Place::ty_from(place_ref.base, proj_base, &self.fx.mir, cx.tcx());
let base_ty = self.fx.monomorphize(&base_ty);
// ZSTs don't require any actual memory access.

View file

@ -324,7 +324,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
target: mir::BasicBlock,
unwind: Option<mir::BasicBlock>,
) {
let ty = location.ty(self.mir.body(), bx.tcx()).ty;
let ty = location.ty(&self.mir, bx.tcx()).ty;
let ty = self.monomorphize(&ty);
let drop_fn = Instance::resolve_drop_in_place(bx.tcx(), ty);
@ -510,7 +510,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
let extra_args = &args[sig.inputs().len()..];
let extra_args = extra_args.iter().map(|op_arg| {
let op_ty = op_arg.ty(self.mir.body(), bx.tcx());
let op_ty = op_arg.ty(&self.mir, bx.tcx());
self.monomorphize(&op_ty)
}).collect::<Vec<_>>();
@ -569,7 +569,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
// a NOP
let target = destination.as_ref().unwrap().1;
helper.maybe_sideeffect(self.mir, &mut bx, &[target]);
helper.funclet_br(self, &mut bx, destination.as_ref().unwrap().1)
helper.funclet_br(self, &mut bx, target)
}
return;
}
@ -791,7 +791,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
bb: mir::BasicBlock,
) {
let mut bx = self.build_block(bb);
let data = &self.mir.body()[bb];
let mir = self.mir;
let data = &mir[bb];
debug!("codegen_block({:?}={:?})", bb, data);

View file

@ -156,7 +156,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
}).collect();
let (landing_pads, funclets) = create_funclets(&mir, &mut bx, &cleanup_kinds, &block_bxs);
let mir_body = mir.body();
let mir_body: &Body<'_> = &mir;
let mut fx = FunctionCx {
instance,
mir,

View file

@ -594,8 +594,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
let place_ty = mir::Place::ty_from(
place_ref.base,
place_ref.projection,
self.mir.body(),
tcx);
&self.mir,
tcx,
);
self.monomorphize(&place_ty.ty)
}
}

View file

@ -460,7 +460,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}
mir::Rvalue::Discriminant(ref place) => {
let discr_ty = rvalue.ty(self.mir.body(), bx.tcx());
let discr_ty = rvalue.ty(&self.mir, bx.tcx());
let discr = self.codegen_place(&mut bx, &place.as_ref())
.codegen_get_discr(&mut bx, discr_ty);
(bx, OperandRef {
@ -513,7 +513,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
mir::Rvalue::Aggregate(..) => {
// According to `rvalue_creates_operand`, only ZST
// aggregate rvalues are allowed to be operands.
let ty = rvalue.ty(self.mir.body(), self.cx.tcx());
let ty = rvalue.ty(&self.mir, self.cx.tcx());
let operand = OperandRef::new_zst(
&mut bx,
self.cx.layout_of(self.monomorphize(&ty)),
@ -710,7 +710,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
true,
mir::Rvalue::Repeat(..) |
mir::Rvalue::Aggregate(..) => {
let ty = rvalue.ty(self.mir.body(), self.cx.tcx());
let ty = rvalue.ty(&self.mir, self.cx.tcx());
let ty = self.monomorphize(&ty);
self.cx.spanned_layout_of(ty, span).is_zst()
}

View file

@ -130,7 +130,7 @@ impl<'tcx> BorrowSet<'tcx> {
) -> Self {
let mut visitor = GatherBorrows {
tcx,
body: body_cache.body(),
body: &body_cache,
idx_vec: IndexVec::new(),
location_map: Default::default(),
activation_map: Default::default(),

View file

@ -208,7 +208,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let ty = Place::ty_from(
used_place.base,
used_place.projection,
self.body_cache.body(),
&self.body_cache,
self.infcx.tcx
).ty;
let needs_note = match ty.kind {
@ -225,7 +225,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let mpi = self.move_data.moves[move_out_indices[0]].path;
let place = &self.move_data.move_paths[mpi].place;
let ty = place.ty(self.body_cache.body(), self.infcx.tcx).ty;
let ty = place.ty(&self.body_cache, self.infcx.tcx).ty;
let opt_name =
self.describe_place_with_options(place.as_ref(), IncludingDowncast(true));
let note_msg = match opt_name {
@ -625,7 +625,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let ty = Place::ty_from(
place_base,
place_projection,
self.body_cache.body(),
&self.body_cache,
self.infcx.tcx
).ty;
ty.ty_adt_def().filter(|adt| adt.is_union()).map(|_| ty)
@ -1635,7 +1635,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
Place::ty_from(
&place.base,
proj_base,
self.body_cache.body(),
&self.body_cache,
tcx
).ty.is_box(),
"Drop of value behind a reference or raw pointer"
@ -1648,7 +1648,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let base_ty = Place::ty_from(
&place.base,
proj_base,
self.body_cache.body(),
&self.body_cache,
tcx
).ty;
match base_ty.kind {

View file

@ -372,7 +372,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let base_ty = Place::ty_from(
place.base,
place.projection,
self.body_cache.body(),
&self.body_cache,
self.infcx.tcx).ty;
self.describe_field_from_ty(&base_ty, field, Some(*variant_index))
}
@ -502,7 +502,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
..
}) = bbd.terminator {
if let Some(source) = BorrowedContentSource::from_call(
func.ty(self.body_cache.body(), tcx),
func.ty(&self.body_cache, tcx),
tcx
) {
return source;
@ -519,7 +519,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let base_ty = Place::ty_from(
deref_base.base,
deref_base.projection,
self.body_cache.body(),
&self.body_cache,
tcx
).ty;
if base_ty.is_unsafe_ptr() {

View file

@ -646,7 +646,7 @@ impl<'cx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tcx
let tcx = self.infcx.tcx;
// Compute the type with accurate region information.
let drop_place_ty = drop_place.ty(self.body_cache.body(), self.infcx.tcx);
let drop_place_ty = drop_place.ty(&self.body_cache, self.infcx.tcx);
// Erase the regions.
let drop_place_ty = self.infcx.tcx.erase_regions(&drop_place_ty).ty;
@ -990,7 +990,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let mut error_reported = false;
let tcx = self.infcx.tcx;
let body = self.body_cache.body();
let body_cache = self.body_cache;
let body: &Body<'_> = &body_cache;
let param_env = self.param_env;
let location_table = self.location_table.start_index(location);
let borrow_set = self.borrow_set.clone();
@ -1341,7 +1342,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
_ => bug!("temporary initialized in arguments"),
};
let bbd = &self.body_cache.body()[loc.block];
let body_cache = self.body_cache;
let bbd = &body_cache[loc.block];
let stmt = &bbd.statements[loc.statement_index];
debug!("temporary assigned in: stmt={:?}", stmt);

View file

@ -300,7 +300,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
// Inspect the type of the content behind the
// borrow to provide feedback about why this
// was a move rather than a copy.
let ty = deref_target_place.ty(self.body_cache.body(), self.infcx.tcx).ty;
let ty = deref_target_place.ty(&self.body_cache, self.infcx.tcx).ty;
let upvar_field = self.prefixes(move_place.as_ref(), PrefixSet::All)
.find_map(|p| self.is_upvar_field_projection(p));
@ -411,7 +411,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
};
let move_ty = format!(
"{:?}",
move_place.ty(self.body_cache.body(), self.infcx.tcx).ty,
move_place.ty(&self.body_cache, self.infcx.tcx).ty,
);
if let Ok(snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(span) {
let is_option = move_ty.starts_with("std::option::Option");
@ -454,7 +454,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
}
if binds_to.is_empty() {
let place_ty = move_from.ty(self.body_cache.body(), self.infcx.tcx).ty;
let place_ty = move_from.ty(&self.body_cache, self.infcx.tcx).ty;
let place_desc = match self.describe_place(move_from.as_ref()) {
Some(desc) => format!("`{}`", desc),
None => format!("value"),
@ -482,7 +482,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
// No binding. Nothing to suggest.
GroupedMoveError::OtherIllegalMove { ref original_path, use_spans, .. } => {
let span = use_spans.var_or_use();
let place_ty = original_path.ty(self.body_cache.body(), self.infcx.tcx).ty;
let place_ty = original_path.ty(&self.body_cache, self.infcx.tcx).ty;
let place_desc = match self.describe_place(original_path.as_ref()) {
Some(desc) => format!("`{}`", desc),
None => format!("value"),

View file

@ -64,7 +64,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
Place::ty_from(
&the_place_err.base,
proj_base,
self.body_cache.body(),
&self.body_cache,
self.infcx.tcx
).ty));
@ -115,7 +115,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
Place::ty_from(
the_place_err.base,
the_place_err.projection,
self.body_cache.body(),
&self.body_cache,
self.infcx.tcx
)
.ty
@ -229,7 +229,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
if let Some((span, message)) = annotate_struct_field(
self.infcx.tcx,
Place::ty_from(base, proj_base, self.body_cache.body(), self.infcx.tcx).ty,
Place::ty_from(base, proj_base, &self.body_cache, self.infcx.tcx).ty,
field,
) {
err.span_suggestion(
@ -304,7 +304,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
projection: [proj_base @ .., ProjectionElem::Field(upvar_index, _)],
} => {
debug_assert!(is_closure_or_generator(
Place::ty_from(base, proj_base, self.body_cache.body(), self.infcx.tcx).ty
Place::ty_from(base, proj_base, &self.body_cache, self.infcx.tcx).ty
));
err.span_label(span, format!("cannot {ACT}", ACT = act));

View file

@ -237,7 +237,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
);
let regioncx = &self.nonlexical_regioncx;
let body = self.body_cache.body();
let body: &Body<'_> = &self.body_cache;
let tcx = self.infcx.tcx;
let borrow_region_vid = borrow.region;

View file

@ -38,7 +38,7 @@ pub(super) fn generate_invalidates<'tcx>(
param_env,
tcx,
location_table,
body: body_cache.body(),
body: &body_cache,
dominators,
};
ig.visit_body(body_cache);

View file

@ -181,7 +181,8 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>(
let universal_regions = Rc::new(universal_regions);
let elements = &Rc::new(RegionValueElements::new(body_cache.body()));
let elements
= &Rc::new(RegionValueElements::new(&body_cache));
// Run the MIR type-checker.
let MirTypeckResults {
@ -206,7 +207,7 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>(
all_facts
.universal_region
.extend(universal_regions.universal_regions());
populate_polonius_move_facts(all_facts, move_data, location_table, body_cache.body());
populate_polonius_move_facts(all_facts, move_data, location_table, &body_cache);
}
// Create the region inference context, taking ownership of the
@ -230,7 +231,7 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>(
&mut liveness_constraints,
&mut all_facts,
location_table,
body_cache.body(),
&body_cache,
borrow_set,
);
@ -239,7 +240,6 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>(
universal_regions,
placeholder_indices,
universal_region_relations,
body_cache.body(),
outlives_constraints,
member_constraints,
closure_bounds_mapping,
@ -284,14 +284,14 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>(
// Solve the region constraints.
let closure_region_requirements =
regioncx.solve(infcx, body_cache.body(), local_names, upvars, def_id, errors_buffer);
regioncx.solve(infcx, &body_cache, local_names, upvars, def_id, errors_buffer);
// Dump MIR results into a file, if that is enabled. This let us
// write unit-tests, as well as helping with debugging.
dump_mir_results(
infcx,
MirSource::item(def_id),
body_cache.body(),
&body_cache,
&regioncx,
&closure_region_requirements,
);
@ -300,7 +300,7 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>(
// information
dump_annotation(
infcx,
body_cache.body(),
&body_cache,
def_id,
&regioncx,
&closure_region_requirements,

View file

@ -239,7 +239,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
universal_regions: Rc<UniversalRegions<'tcx>>,
placeholder_indices: Rc<PlaceholderIndices>,
universal_region_relations: Rc<UniversalRegionRelations<'tcx>>,
_body: &Body<'tcx>,
outlives_constraints: OutlivesConstraintSet,
member_constraints_in: MemberConstraintSet<'tcx, RegionVid>,
closure_bounds_mapping: FxHashMap<

View file

@ -169,7 +169,7 @@ pub(crate) fn type_check<'tcx>(
&universal_region_relations,
|mut cx| {
cx.equate_inputs_and_outputs(
body_cache.body(),
&body_cache,
universal_regions,
&normalized_inputs_and_output);
liveness::generate(
@ -201,7 +201,7 @@ fn type_check_internal<'a, 'tcx, R>(
borrowck_context: &'a mut BorrowCheckContext<'a, 'tcx>,
universal_region_relations: &'a UniversalRegionRelations<'tcx>,
mut extra: impl FnMut(&mut TypeChecker<'a, 'tcx>) -> R,
) -> R where {
) -> R {
let mut checker = TypeChecker::new(
infcx,
body_cache.body(),
@ -220,7 +220,7 @@ fn type_check_internal<'a, 'tcx, R>(
if !errors_reported {
// if verifier failed, don't do further checks to avoid ICEs
checker.typeck_mir(body_cache.body());
checker.typeck_mir(&body_cache);
}
extra(&mut checker)

View file

@ -11,7 +11,7 @@ use super::MirBorrowckCtxt;
use rustc::hir;
use rustc::ty::{self, TyCtxt};
use rustc::mir::{Body, Place, PlaceBase, PlaceRef, ProjectionElem};
use rustc::mir::{Place, PlaceBase, PlaceRef, ProjectionElem, ReadOnlyBodyCache};
pub trait IsPrefixOf<'cx, 'tcx> {
fn is_prefix_of(&self, other: PlaceRef<'cx, 'tcx>) -> bool;
@ -26,7 +26,7 @@ impl<'cx, 'tcx> IsPrefixOf<'cx, 'tcx> for PlaceRef<'cx, 'tcx> {
}
pub(super) struct Prefixes<'cx, 'tcx> {
body: &'cx Body<'tcx>,
body_cache: ReadOnlyBodyCache<'cx, 'tcx>,
tcx: TyCtxt<'tcx>,
kind: PrefixSet,
next: Option<PlaceRef<'cx, 'tcx>>,
@ -56,7 +56,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
Prefixes {
next: Some(place_ref),
kind,
body: self.body_cache.body(),
body_cache: self.body_cache,
tcx: self.infcx.tcx,
}
}
@ -143,7 +143,7 @@ impl<'cx, 'tcx> Iterator for Prefixes<'cx, 'tcx> {
// derefs, except we stop at the deref of a shared
// reference.
let ty = Place::ty_from(cursor.base, proj_base, self.body, self.tcx).ty;
let ty = Place::ty_from(cursor.base, proj_base, &self.body_cache, self.tcx).ty;
match ty.kind {
ty::RawPtr(_) |
ty::Ref(

View file

@ -1249,11 +1249,10 @@ fn collect_neighbours<'tcx>(
) {
debug!("collect_neighbours: {:?}", instance.def_id());
let body_cache = tcx.instance_mir(instance.def);
let body = body_cache.body();
MirNeighborCollector {
tcx,
body: &body,
body: &body_cache,
output,
param_substs: instance.substs,
}.visit_body(body_cache);

View file

@ -113,7 +113,7 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> &'tcx
bug!("creating shims from intrinsics ({:?}) is unsupported", instance)
}
};
debug!("make_shim({:?}) = untransformed {:?}", instance, result.body());
debug!("make_shim({:?}) = untransformed {:?}", instance, result);
run_passes(tcx, &mut result, instance, None, MirPhase::Const, &[
&add_moves_for_packed_drops::AddMovesForPackedDrops,
@ -123,7 +123,7 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> &'tcx
&add_call_guards::CriticalCallEdges,
]);
debug!("make_shim({:?}) = {:?}", instance, result.body());
debug!("make_shim({:?}) = {:?}", instance, result);
result.ensure_predecessors();
tcx.arena.alloc(result)
@ -220,8 +220,8 @@ fn build_drop_shim<'tcx>(
let patch = {
let param_env = tcx.param_env(def_id).with_reveal_all();
let mut elaborator = DropShimElaborator {
body: body_cache.body(),
patch: MirPatch::new(body_cache.body()),
body: &body_cache,
patch: MirPatch::new(&body_cache),
tcx,
param_env
};

View file

@ -529,7 +529,7 @@ fn unsafety_check_result(tcx: TyCtxt<'_>, def_id: DefId) -> UnsafetyCheckResult
};
let mut checker = UnsafetyChecker::new(const_context, min_const_fn, body_cache, tcx, param_env);
let mut cache = body_cache.cache().clone();
let read_only_cache = ReadOnlyBodyCache::from_external_cache(&mut cache, body_cache.body());
let read_only_cache = ReadOnlyBodyCache::from_external_cache(&mut cache, body_cache);
checker.visit_body(read_only_cache);
check_unused_unsafe(tcx, def_id, &checker.used_unsafe, &mut checker.inherited_blocks);

View file

@ -487,7 +487,7 @@ fn locals_live_across_suspend_points(
) -> LivenessInfo {
let dead_unwinds = BitSet::new_empty(body_cache.basic_blocks().len());
let def_id = source.def_id();
let body = body_cache.body();
let body: &Body<'_> = &body_cache;
// Calculate when MIR locals have live storage. This gives us an upper bound of their
// lifetimes.
@ -932,7 +932,7 @@ fn create_generator_drop_shim<'tcx>(
) -> BodyCache<'tcx> {
let mut body_cache = body_cache.clone();
let source_info = source_info(body_cache.body());
let source_info = source_info(&body_cache);
let mut cases = create_cases(&mut body_cache, transform, |point| point.drop);

View file

@ -448,7 +448,7 @@ impl Inliner<'tcx> {
BorrowKind::Mut { allow_two_phase_borrow: false },
destination.0);
let ty = dest.ty(caller_body.body(), self.tcx);
let ty = dest.ty(caller_body, self.tcx);
let temp = LocalDecl::new_temp(ty, callsite.location.span);
@ -553,7 +553,7 @@ impl Inliner<'tcx> {
assert!(args.next().is_none());
let tuple = Place::from(tuple);
let tuple_tys = if let ty::Tuple(s) = tuple.ty(caller_body_cache.body(), tcx).ty.kind {
let tuple_tys = if let ty::Tuple(s) = tuple.ty(caller_body_cache, tcx).ty.kind {
s
} else {
bug!("Closure arguments are not passed as a tuple");
@ -608,7 +608,7 @@ impl Inliner<'tcx> {
// Otherwise, create a temporary for the arg
let arg = Rvalue::Use(arg);
let ty = arg.ty(caller_body_cache.body(), self.tcx);
let ty = arg.ty(caller_body_cache, self.tcx);
let arg_tmp = LocalDecl::new_temp(ty, callsite.location.span);
let arg_tmp = caller_body_cache.local_decls.push(arg_tmp);

View file

@ -13,7 +13,7 @@ pub fn remove_noop_landing_pads<'tcx>(tcx: TyCtxt<'tcx>, body_cache: &mut BodyCa
if tcx.sess.no_landing_pads() {
return
}
debug!("remove_noop_landing_pads({:?})", body_cache.body());
debug!("remove_noop_landing_pads({:?})", body_cache);
RemoveNoopLandingPads.remove_nop_landing_pads(body_cache)
}

View file

@ -58,15 +58,15 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
|_, i| DebugFormatted::new(&i));
if has_rustc_mir_with(&attributes, sym::rustc_peek_maybe_init).is_some() {
sanity_check_via_rustc_peek(tcx, body_cache.body(), def_id, &attributes, &flow_inits);
sanity_check_via_rustc_peek(tcx, body_cache, def_id, &attributes, &flow_inits);
}
if has_rustc_mir_with(&attributes, sym::rustc_peek_maybe_uninit).is_some() {
sanity_check_via_rustc_peek(tcx, body_cache.body(), def_id, &attributes, &flow_uninits);
sanity_check_via_rustc_peek(tcx, body_cache, def_id, &attributes, &flow_uninits);
}
if has_rustc_mir_with(&attributes, sym::rustc_peek_definite_init).is_some() {
sanity_check_via_rustc_peek(
tcx,
body_cache.body(),
body_cache,
def_id,
&attributes,
&flow_def_inits);
@ -74,7 +74,7 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
if has_rustc_mir_with(&attributes, sym::rustc_peek_indirectly_mutable).is_some() {
sanity_check_via_rustc_peek(
tcx,
body_cache.body(),
body_cache,
def_id,
&attributes,
&flow_indirectly_mut);

View file

@ -59,7 +59,7 @@ impl<'tcx> MirPass<'tcx> for SimplifyCfg {
fn run_pass(
&self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx>
) {
debug!("SimplifyCfg({:?}) - simplifying {:?}", self.label, body_cache.body());
debug!("SimplifyCfg({:?}) - simplifying {:?}", self.label, body_cache);
simplify_cfg(body_cache);
}
}
@ -264,7 +264,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
pub fn remove_dead_blocks(body_cache: &mut BodyCache<'_>) {
let mut seen = BitSet::new_empty(body_cache.basic_blocks().len());
for (bb, _) in traversal::preorder(body_cache.body()) {
for (bb, _) in traversal::preorder(body_cache) {
seen.insert(bb.index());
}

View file

@ -223,7 +223,7 @@ impl<'tcx> MirPass<'tcx> for RestoreSubsliceArrayMoveOut<'tcx> {
let src_ty = Place::ty_from(
src_place.base,
src_place.projection,
body_cache.body(),
body_cache,
tcx
).ty;
if let ty::Array(_, ref size_o) = src_ty.kind {

View file

@ -85,7 +85,7 @@ pub fn liveness_of_locals(
// any benefits. Benchmark this and find out.
let mut dirty_queue: WorkQueue<BasicBlock>
= WorkQueue::with_none(body_cache.basic_blocks().len());
for (bb, _) in traversal::postorder(body_cache.body()) {
for (bb, _) in traversal::postorder(&body_cache) {
dirty_queue.insert(bb);
}