Rollup merge of #62096 - spastorino:impl-place-from, r=oli-obk,Centril
Implement From<Local> for Place and PlaceBase r? @oli-obk More tiny bits of Place 2.0 moved into master
This commit is contained in:
commit
d406d89b31
@ -2096,6 +2096,18 @@ fn iterate2<R>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Local> for Place<'_> {
|
||||||
|
fn from(local: Local) -> Self {
|
||||||
|
Place::Base(local.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Local> for PlaceBase<'_> {
|
||||||
|
fn from(local: Local) -> Self {
|
||||||
|
PlaceBase::Local(local)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A linked list of projections running up the stack; begins with the
|
/// A linked list of projections running up the stack; begins with the
|
||||||
/// innermost projection and extends to the outermost (e.g., `a.b.c`
|
/// innermost projection and extends to the outermost (e.g., `a.b.c`
|
||||||
/// would have the place `b` with a "next" pointer to `b.c`).
|
/// would have the place `b` with a "next" pointer to `b.c`).
|
||||||
|
@ -470,7 +470,7 @@ pub fn codegen_place(
|
|||||||
}
|
}
|
||||||
mir::ProjectionElem::Index(index) => {
|
mir::ProjectionElem::Index(index) => {
|
||||||
let index = &mir::Operand::Copy(
|
let index = &mir::Operand::Copy(
|
||||||
mir::Place::Base(mir::PlaceBase::Local(index))
|
mir::Place::from(index)
|
||||||
);
|
);
|
||||||
let index = self.codegen_operand(bx, index);
|
let index = self.codegen_operand(bx, index);
|
||||||
let llindex = index.immediate();
|
let llindex = index.immediate();
|
||||||
|
@ -627,7 +627,7 @@ pub(super) fn borrow_spans(&self, use_span: Span, location: Location) -> UseSpan
|
|||||||
def_id, is_generator, places
|
def_id, is_generator, places
|
||||||
);
|
);
|
||||||
if let Some((args_span, var_span)) = self.closure_span(
|
if let Some((args_span, var_span)) = self.closure_span(
|
||||||
*def_id, &Place::Base(PlaceBase::Local(target)), places
|
*def_id, &Place::from(target), places
|
||||||
) {
|
) {
|
||||||
return ClosureUse {
|
return ClosureUse {
|
||||||
is_generator,
|
is_generator,
|
||||||
|
@ -620,7 +620,7 @@ fn visit_statement_entry(
|
|||||||
StatementKind::StorageDead(local) => {
|
StatementKind::StorageDead(local) => {
|
||||||
self.access_place(
|
self.access_place(
|
||||||
location,
|
location,
|
||||||
(&Place::Base(PlaceBase::Local(local)), span),
|
(&Place::from(local), span),
|
||||||
(Shallow(None), Write(WriteKind::StorageDeadOrDrop)),
|
(Shallow(None), Write(WriteKind::StorageDeadOrDrop)),
|
||||||
LocalMutationIsAllowed::Yes,
|
LocalMutationIsAllowed::Yes,
|
||||||
flow_state,
|
flow_state,
|
||||||
|
@ -252,7 +252,7 @@ pub(in crate::borrow_check) fn explain_why_borrow_contains_point(
|
|||||||
Some(Cause::LiveVar(local, location)) => {
|
Some(Cause::LiveVar(local, location)) => {
|
||||||
let span = body.source_info(location).span;
|
let span = body.source_info(location).span;
|
||||||
let spans = self
|
let spans = self
|
||||||
.move_spans(&Place::Base(PlaceBase::Local(local)), location)
|
.move_spans(&Place::from(local), location)
|
||||||
.or_else(|| self.borrow_spans(span, location));
|
.or_else(|| self.borrow_spans(span, location));
|
||||||
|
|
||||||
let borrow_location = location;
|
let borrow_location = location;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
use crate::dataflow::indexes::BorrowIndex;
|
use crate::dataflow::indexes::BorrowIndex;
|
||||||
use rustc::ty::TyCtxt;
|
use rustc::ty::TyCtxt;
|
||||||
use rustc::mir::visit::Visitor;
|
use rustc::mir::visit::Visitor;
|
||||||
use rustc::mir::{BasicBlock, Location, Body, Place, PlaceBase, Rvalue};
|
use rustc::mir::{BasicBlock, Location, Body, Place, Rvalue};
|
||||||
use rustc::mir::{Statement, StatementKind};
|
use rustc::mir::{Statement, StatementKind};
|
||||||
use rustc::mir::TerminatorKind;
|
use rustc::mir::TerminatorKind;
|
||||||
use rustc::mir::{Operand, BorrowKind};
|
use rustc::mir::{Operand, BorrowKind};
|
||||||
@ -124,7 +124,7 @@ fn visit_statement(
|
|||||||
StatementKind::StorageDead(local) => {
|
StatementKind::StorageDead(local) => {
|
||||||
self.access_place(
|
self.access_place(
|
||||||
location,
|
location,
|
||||||
&Place::Base(PlaceBase::Local(local)),
|
&Place::from(local),
|
||||||
(Shallow(None), Write(WriteKind::StorageDeadOrDrop)),
|
(Shallow(None), Write(WriteKind::StorageDeadOrDrop)),
|
||||||
LocalMutationIsAllowed::Yes,
|
LocalMutationIsAllowed::Yes,
|
||||||
);
|
);
|
||||||
|
@ -632,7 +632,7 @@ fn sanitize_projection(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
ProjectionElem::Index(i) => {
|
ProjectionElem::Index(i) => {
|
||||||
let index_ty = Place::Base(PlaceBase::Local(i)).ty(self.body, tcx).ty;
|
let index_ty = Place::from(i).ty(self.body, tcx).ty;
|
||||||
if index_ty != tcx.types.usize {
|
if index_ty != tcx.types.usize {
|
||||||
PlaceTy::from_ty(
|
PlaceTy::from_ty(
|
||||||
span_mirbug_and_err!(self, i, "index by non-usize {:?}", i),
|
span_mirbug_and_err!(self, i, "index by non-usize {:?}", i),
|
||||||
|
@ -74,7 +74,7 @@ fn expr_as_operand(
|
|||||||
}
|
}
|
||||||
Category::Place | Category::Rvalue(..) => {
|
Category::Place | Category::Rvalue(..) => {
|
||||||
let operand = unpack!(block = this.as_temp(block, scope, expr, Mutability::Mut));
|
let operand = unpack!(block = this.as_temp(block, scope, expr, Mutability::Mut));
|
||||||
block.and(Operand::Move(Place::Base(PlaceBase::Local(operand))))
|
block.and(Operand::Move(Place::from(operand)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,26 +98,26 @@ fn expr_as_place(
|
|||||||
<,
|
<,
|
||||||
Rvalue::BinaryOp(
|
Rvalue::BinaryOp(
|
||||||
BinOp::Lt,
|
BinOp::Lt,
|
||||||
Operand::Copy(Place::Base(PlaceBase::Local(idx))),
|
Operand::Copy(Place::from(idx)),
|
||||||
Operand::Copy(len.clone()),
|
Operand::Copy(len.clone()),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
let msg = BoundsCheck {
|
let msg = BoundsCheck {
|
||||||
len: Operand::Move(len),
|
len: Operand::Move(len),
|
||||||
index: Operand::Copy(Place::Base(PlaceBase::Local(idx))),
|
index: Operand::Copy(Place::from(idx)),
|
||||||
};
|
};
|
||||||
let success = this.assert(block, Operand::Move(lt), true, msg, expr_span);
|
let success = this.assert(block, Operand::Move(lt), true, msg, expr_span);
|
||||||
success.and(slice.index(idx))
|
success.and(slice.index(idx))
|
||||||
}
|
}
|
||||||
ExprKind::SelfRef => block.and(Place::Base(PlaceBase::Local(Local::new(1)))),
|
ExprKind::SelfRef => block.and(Place::from(Local::new(1))),
|
||||||
ExprKind::VarRef { id } => {
|
ExprKind::VarRef { id } => {
|
||||||
let place = if this.is_bound_var_in_guard(id) {
|
let place = if this.is_bound_var_in_guard(id) {
|
||||||
let index = this.var_local_id(id, RefWithinGuard);
|
let index = this.var_local_id(id, RefWithinGuard);
|
||||||
Place::Base(PlaceBase::Local(index)).deref()
|
Place::from(index).deref()
|
||||||
} else {
|
} else {
|
||||||
let index = this.var_local_id(id, OutsideGuard);
|
let index = this.var_local_id(id, OutsideGuard);
|
||||||
Place::Base(PlaceBase::Local(index))
|
Place::from(index)
|
||||||
};
|
};
|
||||||
block.and(place)
|
block.and(place)
|
||||||
}
|
}
|
||||||
@ -168,14 +168,14 @@ fn expr_as_place(
|
|||||||
Statement {
|
Statement {
|
||||||
source_info,
|
source_info,
|
||||||
kind: StatementKind::AscribeUserType(
|
kind: StatementKind::AscribeUserType(
|
||||||
Place::Base(PlaceBase::Local(temp.clone())),
|
Place::from(temp.clone()),
|
||||||
Variance::Invariant,
|
Variance::Invariant,
|
||||||
box UserTypeProjection { base: annotation_index, projs: vec![], },
|
box UserTypeProjection { base: annotation_index, projs: vec![], },
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
block.and(Place::Base(PlaceBase::Local(temp)))
|
block.and(Place::from(temp))
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprKind::Array { .. }
|
ExprKind::Array { .. }
|
||||||
@ -211,7 +211,7 @@ fn expr_as_place(
|
|||||||
});
|
});
|
||||||
let temp =
|
let temp =
|
||||||
unpack!(block = this.as_temp(block, expr.temp_lifetime, expr, mutability));
|
unpack!(block = this.as_temp(block, expr.temp_lifetime, expr, mutability));
|
||||||
block.and(Place::Base(PlaceBase::Local(temp)))
|
block.and(Place::from(temp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ fn expr_as_rvalue(
|
|||||||
this.schedule_drop_storage_and_value(
|
this.schedule_drop_storage_and_value(
|
||||||
expr_span,
|
expr_span,
|
||||||
scope,
|
scope,
|
||||||
&Place::Base(PlaceBase::Local(result)),
|
&Place::from(result),
|
||||||
value.ty,
|
value.ty,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -135,16 +135,16 @@ fn expr_as_rvalue(
|
|||||||
// malloc some memory of suitable type (thus far, uninitialized):
|
// malloc some memory of suitable type (thus far, uninitialized):
|
||||||
let box_ = Rvalue::NullaryOp(NullOp::Box, value.ty);
|
let box_ = Rvalue::NullaryOp(NullOp::Box, value.ty);
|
||||||
this.cfg
|
this.cfg
|
||||||
.push_assign(block, source_info, &Place::Base(PlaceBase::Local(result)), box_);
|
.push_assign(block, source_info, &Place::from(result), box_);
|
||||||
|
|
||||||
// initialize the box contents:
|
// initialize the box contents:
|
||||||
unpack!(
|
unpack!(
|
||||||
block = this.into(
|
block = this.into(
|
||||||
&Place::Base(PlaceBase::Local(result)).deref(),
|
&Place::from(result).deref(),
|
||||||
block, value
|
block, value
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
block.and(Rvalue::Use(Operand::Move(Place::Base(PlaceBase::Local(result)))))
|
block.and(Rvalue::Use(Operand::Move(Place::from(result))))
|
||||||
}
|
}
|
||||||
ExprKind::Cast { source } => {
|
ExprKind::Cast { source } => {
|
||||||
let source = unpack!(block = this.as_operand(block, scope, source));
|
let source = unpack!(block = this.as_operand(block, scope, source));
|
||||||
@ -548,7 +548,7 @@ fn limit_capture_mutability(
|
|||||||
this.cfg.push_assign(
|
this.cfg.push_assign(
|
||||||
block,
|
block,
|
||||||
source_info,
|
source_info,
|
||||||
&Place::Base(PlaceBase::Local(temp)),
|
&Place::from(temp),
|
||||||
Rvalue::Ref(this.hir.tcx().lifetimes.re_erased, borrow_kind, arg_place),
|
Rvalue::Ref(this.hir.tcx().lifetimes.re_erased, borrow_kind, arg_place),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -559,12 +559,12 @@ fn limit_capture_mutability(
|
|||||||
this.schedule_drop_storage_and_value(
|
this.schedule_drop_storage_and_value(
|
||||||
upvar_span,
|
upvar_span,
|
||||||
temp_lifetime,
|
temp_lifetime,
|
||||||
&Place::Base(PlaceBase::Local(temp)),
|
&Place::from(temp),
|
||||||
upvar_ty,
|
upvar_ty,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
block.and(Operand::Move(Place::Base(PlaceBase::Local(temp))))
|
block.and(Operand::Move(Place::from(temp)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper to get a `-1` value of the appropriate type
|
// Helper to get a `-1` value of the appropriate type
|
||||||
|
@ -64,7 +64,7 @@ fn expr_as_temp(
|
|||||||
}
|
}
|
||||||
this.local_decls.push(local_decl)
|
this.local_decls.push(local_decl)
|
||||||
};
|
};
|
||||||
let temp_place = &Place::Base(PlaceBase::Local(temp));
|
let temp_place = &Place::from(temp);
|
||||||
|
|
||||||
if !expr_ty.is_never() {
|
if !expr_ty.is_never() {
|
||||||
this.cfg.push(
|
this.cfg.push(
|
||||||
|
@ -258,7 +258,7 @@ pub fn into_expr(
|
|||||||
is_user_variable: None,
|
is_user_variable: None,
|
||||||
is_block_tail: None,
|
is_block_tail: None,
|
||||||
});
|
});
|
||||||
let ptr_temp = Place::Base(PlaceBase::Local(ptr_temp));
|
let ptr_temp = Place::from(ptr_temp);
|
||||||
let block = unpack!(this.into(&ptr_temp, block, ptr));
|
let block = unpack!(this.into(&ptr_temp, block, ptr));
|
||||||
this.into(&ptr_temp.deref(), block, val)
|
this.into(&ptr_temp.deref(), block, val)
|
||||||
} else {
|
} else {
|
||||||
|
@ -235,7 +235,7 @@ pub fn stmt_expr(&mut self,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let temp = this.local_decls.push(local_decl);
|
let temp = this.local_decls.push(local_decl);
|
||||||
let place = Place::Base(PlaceBase::Local(temp));
|
let place = Place::from(temp);
|
||||||
debug!("created temp {:?} for expr {:?} in block_context: {:?}",
|
debug!("created temp {:?} for expr {:?} in block_context: {:?}",
|
||||||
temp, expr, this.block_context);
|
temp, expr, this.block_context);
|
||||||
place
|
place
|
||||||
|
@ -531,7 +531,7 @@ pub fn storage_live_binding(
|
|||||||
kind: StatementKind::StorageLive(local_id),
|
kind: StatementKind::StorageLive(local_id),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
let place = Place::Base(PlaceBase::Local(local_id));
|
let place = Place::from(local_id);
|
||||||
let var_ty = self.local_decls[local_id].ty;
|
let var_ty = self.local_decls[local_id].ty;
|
||||||
let region_scope = self.hir.region_scope_tree.var_scope(var.local_id);
|
let region_scope = self.hir.region_scope_tree.var_scope(var.local_id);
|
||||||
self.schedule_drop(span, region_scope, &place, var_ty, DropKind::Storage);
|
self.schedule_drop(span, region_scope, &place, var_ty, DropKind::Storage);
|
||||||
@ -545,7 +545,7 @@ pub fn schedule_drop_for_binding(&mut self, var: HirId, span: Span, for_guard: F
|
|||||||
self.schedule_drop(
|
self.schedule_drop(
|
||||||
span,
|
span,
|
||||||
region_scope,
|
region_scope,
|
||||||
&Place::Base(PlaceBase::Local(local_id)),
|
&Place::from(local_id),
|
||||||
var_ty,
|
var_ty,
|
||||||
DropKind::Value,
|
DropKind::Value,
|
||||||
);
|
);
|
||||||
@ -1478,7 +1478,7 @@ fn bind_and_guard_matched_candidate<'pat>(
|
|||||||
self.cfg.push_assign(
|
self.cfg.push_assign(
|
||||||
block,
|
block,
|
||||||
scrutinee_source_info,
|
scrutinee_source_info,
|
||||||
&Place::Base(PlaceBase::Local(temp)),
|
&Place::from(temp),
|
||||||
borrow,
|
borrow,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1502,7 +1502,7 @@ fn bind_and_guard_matched_candidate<'pat>(
|
|||||||
source_info: guard_end,
|
source_info: guard_end,
|
||||||
kind: StatementKind::FakeRead(
|
kind: StatementKind::FakeRead(
|
||||||
FakeReadCause::ForMatchGuard,
|
FakeReadCause::ForMatchGuard,
|
||||||
Place::Base(PlaceBase::Local(temp)),
|
Place::from(temp),
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1575,7 +1575,7 @@ fn bind_and_guard_matched_candidate<'pat>(
|
|||||||
// place they refer to can't be modified by the guard.
|
// place they refer to can't be modified by the guard.
|
||||||
for binding in by_value_bindings.clone() {
|
for binding in by_value_bindings.clone() {
|
||||||
let local_id = self.var_local_id(binding.var_id, RefWithinGuard);
|
let local_id = self.var_local_id(binding.var_id, RefWithinGuard);
|
||||||
let place = Place::Base(PlaceBase::Local(local_id));
|
let place = Place::from(local_id);
|
||||||
self.cfg.push(
|
self.cfg.push(
|
||||||
block,
|
block,
|
||||||
Statement {
|
Statement {
|
||||||
|
@ -16,7 +16,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
/// call `schedule_drop` once the temporary is initialized.
|
/// call `schedule_drop` once the temporary is initialized.
|
||||||
pub fn temp(&mut self, ty: Ty<'tcx>, span: Span) -> Place<'tcx> {
|
pub fn temp(&mut self, ty: Ty<'tcx>, span: Span) -> Place<'tcx> {
|
||||||
let temp = self.local_decls.push(LocalDecl::new_temp(ty, span));
|
let temp = self.local_decls.push(LocalDecl::new_temp(ty, span));
|
||||||
let place = Place::Base(PlaceBase::Local(temp));
|
let place = Place::from(temp);
|
||||||
debug!("temp: created temp {:?} with type {:?}",
|
debug!("temp: created temp {:?} with type {:?}",
|
||||||
place, self.local_decls[temp].ty);
|
place, self.local_decls[temp].ty);
|
||||||
place
|
place
|
||||||
|
@ -808,7 +808,7 @@ fn args_and_body(&mut self,
|
|||||||
for (index, arg_info) in arguments.iter().enumerate() {
|
for (index, arg_info) in arguments.iter().enumerate() {
|
||||||
// Function arguments always get the first Local indices after the return place
|
// Function arguments always get the first Local indices after the return place
|
||||||
let local = Local::new(index + 1);
|
let local = Local::new(index + 1);
|
||||||
let place = Place::Base(PlaceBase::Local(local));
|
let place = Place::from(local);
|
||||||
let &ArgInfo(ty, opt_ty_info, pattern, ref self_binding) = arg_info;
|
let &ArgInfo(ty, opt_ty_info, pattern, ref self_binding) = arg_info;
|
||||||
|
|
||||||
// Make sure we drop (parts of) the argument even when not matched on.
|
// Make sure we drop (parts of) the argument even when not matched on.
|
||||||
|
@ -170,7 +170,7 @@ pub(crate) fn drop_flag_effects_for_function_entry<'tcx, F>(
|
|||||||
{
|
{
|
||||||
let move_data = &ctxt.move_data;
|
let move_data = &ctxt.move_data;
|
||||||
for arg in body.args_iter() {
|
for arg in body.args_iter() {
|
||||||
let place = mir::Place::Base(mir::PlaceBase::Local(arg));
|
let place = mir::Place::from(arg);
|
||||||
let lookup_result = move_data.rev_lookup.find(&place);
|
let lookup_result = move_data.rev_lookup.find(&place);
|
||||||
on_lookup_result_bits(tcx, body, move_data,
|
on_lookup_result_bits(tcx, body, move_data,
|
||||||
lookup_result,
|
lookup_result,
|
||||||
|
@ -288,7 +288,7 @@ fn statement_effect(&self,
|
|||||||
mir::StatementKind::StorageDead(local) => {
|
mir::StatementKind::StorageDead(local) => {
|
||||||
// Make sure there are no remaining borrows for locals that
|
// Make sure there are no remaining borrows for locals that
|
||||||
// are gone out of scope.
|
// are gone out of scope.
|
||||||
self.kill_borrows_on_place(trans, &Place::Base(PlaceBase::Local(local)));
|
self.kill_borrows_on_place(trans, &Place::from(local));
|
||||||
}
|
}
|
||||||
|
|
||||||
mir::StatementKind::InlineAsm(ref asm) => {
|
mir::StatementKind::InlineAsm(ref asm) => {
|
||||||
|
@ -33,13 +33,13 @@ fn new(body: &'a Body<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
|
|||||||
moves: IndexVec::new(),
|
moves: IndexVec::new(),
|
||||||
loc_map: LocationMap::new(body),
|
loc_map: LocationMap::new(body),
|
||||||
rev_lookup: MovePathLookup {
|
rev_lookup: MovePathLookup {
|
||||||
locals: body.local_decls.indices().map(PlaceBase::Local).map(|v| {
|
locals: body.local_decls.indices().map(|i| {
|
||||||
Self::new_move_path(
|
Self::new_move_path(
|
||||||
&mut move_paths,
|
&mut move_paths,
|
||||||
&mut path_map,
|
&mut path_map,
|
||||||
&mut init_path_map,
|
&mut init_path_map,
|
||||||
None,
|
None,
|
||||||
Place::Base(v),
|
Place::from(i),
|
||||||
)
|
)
|
||||||
}).collect(),
|
}).collect(),
|
||||||
projections: Default::default(),
|
projections: Default::default(),
|
||||||
@ -289,7 +289,7 @@ fn gather_statement(&mut self, stmt: &Statement<'tcx>) {
|
|||||||
}
|
}
|
||||||
StatementKind::StorageLive(_) => {}
|
StatementKind::StorageLive(_) => {}
|
||||||
StatementKind::StorageDead(local) => {
|
StatementKind::StorageDead(local) => {
|
||||||
self.gather_move(&Place::Base(PlaceBase::Local(local)));
|
self.gather_move(&Place::from(local));
|
||||||
}
|
}
|
||||||
StatementKind::SetDiscriminant{ .. } => {
|
StatementKind::SetDiscriminant{ .. } => {
|
||||||
span_bug!(stmt.source_info.span,
|
span_bug!(stmt.source_info.span,
|
||||||
|
@ -355,7 +355,7 @@ fn eval_fn_call(
|
|||||||
let mut locals_iter = body.args_iter();
|
let mut locals_iter = body.args_iter();
|
||||||
while let Some(local) = locals_iter.next() {
|
while let Some(local) = locals_iter.next() {
|
||||||
let dest = self.eval_place(
|
let dest = self.eval_place(
|
||||||
&mir::Place::Base(mir::PlaceBase::Local(local))
|
&mir::Place::from(local)
|
||||||
)?;
|
)?;
|
||||||
if Some(local) == body.spread_arg {
|
if Some(local) == body.spread_arg {
|
||||||
// Must be a tuple
|
// Must be a tuple
|
||||||
|
@ -213,7 +213,7 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>)
|
|||||||
|
|
||||||
if let Some(..) = ty {
|
if let Some(..) = ty {
|
||||||
// The first argument (index 0), but add 1 for the return value.
|
// The first argument (index 0), but add 1 for the return value.
|
||||||
let dropee_ptr = Place::Base(PlaceBase::Local(Local::new(1+0)));
|
let dropee_ptr = Place::from(Local::new(1+0));
|
||||||
if tcx.sess.opts.debugging_opts.mir_emit_retag {
|
if tcx.sess.opts.debugging_opts.mir_emit_retag {
|
||||||
// Function arguments should be retagged, and we make this one raw.
|
// Function arguments should be retagged, and we make this one raw.
|
||||||
body.basic_blocks_mut()[START_BLOCK].statements.insert(0, Statement {
|
body.basic_blocks_mut()[START_BLOCK].statements.insert(0, Statement {
|
||||||
@ -308,7 +308,7 @@ fn build_clone_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, self_ty: Ty<'tcx>) -
|
|||||||
let is_copy = self_ty.is_copy_modulo_regions(tcx, tcx.param_env(def_id), builder.span);
|
let is_copy = self_ty.is_copy_modulo_regions(tcx, tcx.param_env(def_id), builder.span);
|
||||||
|
|
||||||
let dest = Place::RETURN_PLACE;
|
let dest = Place::RETURN_PLACE;
|
||||||
let src = Place::Base(PlaceBase::Local(Local::new(1+0))).deref();
|
let src = Place::from(Local::new(1+0)).deref();
|
||||||
|
|
||||||
match self_ty.sty {
|
match self_ty.sty {
|
||||||
_ if is_copy => builder.copy_shim(),
|
_ if is_copy => builder.copy_shim(),
|
||||||
@ -412,7 +412,7 @@ fn make_statement(&self, kind: StatementKind<'tcx>) -> Statement<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn copy_shim(&mut self) {
|
fn copy_shim(&mut self) {
|
||||||
let rcvr = Place::Base(PlaceBase::Local(Local::new(1+0))).deref();
|
let rcvr = Place::from(Local::new(1+0)).deref();
|
||||||
let ret_statement = self.make_statement(
|
let ret_statement = self.make_statement(
|
||||||
StatementKind::Assign(
|
StatementKind::Assign(
|
||||||
Place::RETURN_PLACE,
|
Place::RETURN_PLACE,
|
||||||
@ -424,9 +424,7 @@ fn copy_shim(&mut self) {
|
|||||||
|
|
||||||
fn make_place(&mut self, mutability: Mutability, ty: Ty<'tcx>) -> Place<'tcx> {
|
fn make_place(&mut self, mutability: Mutability, ty: Ty<'tcx>) -> Place<'tcx> {
|
||||||
let span = self.span;
|
let span = self.span;
|
||||||
Place::Base(PlaceBase::Local(
|
Place::from(self.local_decls.push(temp_decl(mutability, ty, span)))
|
||||||
self.local_decls.push(temp_decl(mutability, ty, span))
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_clone_call(
|
fn make_clone_call(
|
||||||
@ -525,7 +523,7 @@ fn array_shim(&mut self, dest: Place<'tcx>, src: Place<'tcx>, ty: Ty<'tcx>, len:
|
|||||||
let inits = vec![
|
let inits = vec![
|
||||||
self.make_statement(
|
self.make_statement(
|
||||||
StatementKind::Assign(
|
StatementKind::Assign(
|
||||||
Place::Base(PlaceBase::Local(beg)),
|
Place::from(beg),
|
||||||
box Rvalue::Use(Operand::Constant(self.make_usize(0)))
|
box Rvalue::Use(Operand::Constant(self.make_usize(0)))
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@ -543,7 +541,7 @@ fn array_shim(&mut self, dest: Place<'tcx>, src: Place<'tcx>, ty: Ty<'tcx>, len:
|
|||||||
// BB #3;
|
// BB #3;
|
||||||
// }
|
// }
|
||||||
// BB #4;
|
// BB #4;
|
||||||
self.loop_header(Place::Base(PlaceBase::Local(beg)),
|
self.loop_header(Place::from(beg),
|
||||||
end,
|
end,
|
||||||
BasicBlock::new(2),
|
BasicBlock::new(2),
|
||||||
BasicBlock::new(4),
|
BasicBlock::new(4),
|
||||||
@ -563,10 +561,10 @@ fn array_shim(&mut self, dest: Place<'tcx>, src: Place<'tcx>, ty: Ty<'tcx>, len:
|
|||||||
let statements = vec![
|
let statements = vec![
|
||||||
self.make_statement(
|
self.make_statement(
|
||||||
StatementKind::Assign(
|
StatementKind::Assign(
|
||||||
Place::Base(PlaceBase::Local(beg)),
|
Place::from(beg),
|
||||||
box Rvalue::BinaryOp(
|
box Rvalue::BinaryOp(
|
||||||
BinOp::Add,
|
BinOp::Add,
|
||||||
Operand::Copy(Place::Base(PlaceBase::Local(beg))),
|
Operand::Copy(Place::from(beg)),
|
||||||
Operand::Constant(self.make_usize(1))
|
Operand::Constant(self.make_usize(1))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -586,7 +584,7 @@ fn array_shim(&mut self, dest: Place<'tcx>, src: Place<'tcx>, ty: Ty<'tcx>, len:
|
|||||||
let beg = self.local_decls.push(temp_decl(Mutability::Mut, tcx.types.usize, span));
|
let beg = self.local_decls.push(temp_decl(Mutability::Mut, tcx.types.usize, span));
|
||||||
let init = self.make_statement(
|
let init = self.make_statement(
|
||||||
StatementKind::Assign(
|
StatementKind::Assign(
|
||||||
Place::Base(PlaceBase::Local(beg)),
|
Place::from(beg),
|
||||||
box Rvalue::Use(Operand::Constant(self.make_usize(0)))
|
box Rvalue::Use(Operand::Constant(self.make_usize(0)))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -597,7 +595,7 @@ fn array_shim(&mut self, dest: Place<'tcx>, src: Place<'tcx>, ty: Ty<'tcx>, len:
|
|||||||
// BB #8;
|
// BB #8;
|
||||||
// }
|
// }
|
||||||
// BB #9;
|
// BB #9;
|
||||||
self.loop_header(Place::Base(PlaceBase::Local(beg)), Place::Base(PlaceBase::Local(end)),
|
self.loop_header(Place::from(beg), Place::from(end),
|
||||||
BasicBlock::new(7), BasicBlock::new(9), true);
|
BasicBlock::new(7), BasicBlock::new(9), true);
|
||||||
|
|
||||||
// BB #7 (cleanup)
|
// BB #7 (cleanup)
|
||||||
@ -613,10 +611,10 @@ fn array_shim(&mut self, dest: Place<'tcx>, src: Place<'tcx>, ty: Ty<'tcx>, len:
|
|||||||
// `goto #6;`
|
// `goto #6;`
|
||||||
let statement = self.make_statement(
|
let statement = self.make_statement(
|
||||||
StatementKind::Assign(
|
StatementKind::Assign(
|
||||||
Place::Base(PlaceBase::Local(beg)),
|
Place::from(beg),
|
||||||
box Rvalue::BinaryOp(
|
box Rvalue::BinaryOp(
|
||||||
BinOp::Add,
|
BinOp::Add,
|
||||||
Operand::Copy(Place::Base(PlaceBase::Local(beg))),
|
Operand::Copy(Place::from(beg)),
|
||||||
Operand::Constant(self.make_usize(1))
|
Operand::Constant(self.make_usize(1))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -701,7 +699,7 @@ fn build_call_shim<'tcx>(
|
|||||||
let source_info = SourceInfo { span, scope: OUTERMOST_SOURCE_SCOPE };
|
let source_info = SourceInfo { span, scope: OUTERMOST_SOURCE_SCOPE };
|
||||||
|
|
||||||
let rcvr_arg = Local::new(1+0);
|
let rcvr_arg = Local::new(1+0);
|
||||||
let rcvr_l = Place::Base(PlaceBase::Local(rcvr_arg));
|
let rcvr_l = Place::from(rcvr_arg);
|
||||||
let mut statements = vec![];
|
let mut statements = vec![];
|
||||||
|
|
||||||
let rcvr = match rcvr_adjustment {
|
let rcvr = match rcvr_adjustment {
|
||||||
@ -731,11 +729,11 @@ fn build_call_shim<'tcx>(
|
|||||||
statements.push(Statement {
|
statements.push(Statement {
|
||||||
source_info,
|
source_info,
|
||||||
kind: StatementKind::Assign(
|
kind: StatementKind::Assign(
|
||||||
Place::Base(PlaceBase::Local(ref_rcvr)),
|
Place::from(ref_rcvr),
|
||||||
box Rvalue::Ref(tcx.lifetimes.re_erased, borrow_kind, rcvr_l)
|
box Rvalue::Ref(tcx.lifetimes.re_erased, borrow_kind, rcvr_l)
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
Operand::Move(Place::Base(PlaceBase::Local(ref_rcvr)))
|
Operand::Move(Place::from(ref_rcvr))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -755,12 +753,12 @@ fn build_call_shim<'tcx>(
|
|||||||
|
|
||||||
if let Some(untuple_args) = untuple_args {
|
if let Some(untuple_args) = untuple_args {
|
||||||
args.extend(untuple_args.iter().enumerate().map(|(i, ity)| {
|
args.extend(untuple_args.iter().enumerate().map(|(i, ity)| {
|
||||||
let arg_place = Place::Base(PlaceBase::Local(Local::new(1+1)));
|
let arg_place = Place::from(Local::new(1+1));
|
||||||
Operand::Move(arg_place.field(Field::new(i), *ity))
|
Operand::Move(arg_place.field(Field::new(i), *ity))
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
args.extend((1..sig.inputs().len()).map(|i| {
|
args.extend((1..sig.inputs().len()).map(|i| {
|
||||||
Operand::Move(Place::Base(PlaceBase::Local(Local::new(1+i))))
|
Operand::Move(Place::from(Local::new(1+i)))
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -791,7 +789,7 @@ fn build_call_shim<'tcx>(
|
|||||||
if let Adjustment::RefMut = rcvr_adjustment {
|
if let Adjustment::RefMut = rcvr_adjustment {
|
||||||
// BB #1 - drop for Self
|
// BB #1 - drop for Self
|
||||||
block(&mut blocks, vec![], TerminatorKind::Drop {
|
block(&mut blocks, vec![], TerminatorKind::Drop {
|
||||||
location: Place::Base(PlaceBase::Local(rcvr_arg)),
|
location: Place::from(rcvr_arg),
|
||||||
target: BasicBlock::new(2),
|
target: BasicBlock::new(2),
|
||||||
unwind: None
|
unwind: None
|
||||||
}, false);
|
}, false);
|
||||||
@ -801,7 +799,7 @@ fn build_call_shim<'tcx>(
|
|||||||
if let Adjustment::RefMut = rcvr_adjustment {
|
if let Adjustment::RefMut = rcvr_adjustment {
|
||||||
// BB #3 - drop if closure panics
|
// BB #3 - drop if closure panics
|
||||||
block(&mut blocks, vec![], TerminatorKind::Drop {
|
block(&mut blocks, vec![], TerminatorKind::Drop {
|
||||||
location: Place::Base(PlaceBase::Local(rcvr_arg)),
|
location: Place::from(rcvr_arg),
|
||||||
target: BasicBlock::new(4),
|
target: BasicBlock::new(4),
|
||||||
unwind: None
|
unwind: None
|
||||||
}, true);
|
}, true);
|
||||||
@ -881,7 +879,7 @@ pub fn build_adt_ctor<'tcx>(tcx: TyCtxt<'tcx>, ctor_id: DefId) -> &'tcx Body<'tc
|
|||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(idx, field_def)| (
|
.map(|(idx, field_def)| (
|
||||||
Operand::Move(Place::Base(PlaceBase::Local(Local::new(idx + 1)))),
|
Operand::Move(Place::from(Local::new(idx + 1))),
|
||||||
field_def.ty(tcx, substs),
|
field_def.ty(tcx, substs),
|
||||||
)),
|
)),
|
||||||
AggregateKind::Adt(adt_def, variant_index, substs, None, None),
|
AggregateKind::Adt(adt_def, variant_index, substs, None, None),
|
||||||
|
@ -112,10 +112,10 @@ fn add_move_for_packed_drop<'tcx>(
|
|||||||
|
|
||||||
patch.add_statement(
|
patch.add_statement(
|
||||||
loc, StatementKind::StorageLive(temp));
|
loc, StatementKind::StorageLive(temp));
|
||||||
patch.add_assign(loc, Place::Base(PlaceBase::Local(temp)),
|
patch.add_assign(loc, Place::from(temp),
|
||||||
Rvalue::Use(Operand::Move(location.clone())));
|
Rvalue::Use(Operand::Move(location.clone())));
|
||||||
patch.patch_terminator(loc.block, TerminatorKind::Drop {
|
patch.patch_terminator(loc.block, TerminatorKind::Drop {
|
||||||
location: Place::Base(PlaceBase::Local(temp)),
|
location: Place::from(temp),
|
||||||
target: storage_dead_block,
|
target: storage_dead_block,
|
||||||
unwind
|
unwind
|
||||||
});
|
});
|
||||||
|
@ -96,7 +96,7 @@ fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Bo
|
|||||||
};
|
};
|
||||||
// Gather all arguments, skip return value.
|
// Gather all arguments, skip return value.
|
||||||
let places = local_decls.iter_enumerated().skip(1).take(arg_count)
|
let places = local_decls.iter_enumerated().skip(1).take(arg_count)
|
||||||
.map(|(local, _)| Place::Base(PlaceBase::Local(local)))
|
.map(|(local, _)| Place::from(local))
|
||||||
.filter(needs_retag)
|
.filter(needs_retag)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
// Emit their retags.
|
// Emit their retags.
|
||||||
|
@ -326,7 +326,7 @@ fn create_drop_flag(&mut self, index: MovePathIndex, span: Span) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn drop_flag(&mut self, index: MovePathIndex) -> Option<Place<'tcx>> {
|
fn drop_flag(&mut self, index: MovePathIndex) -> Option<Place<'tcx>> {
|
||||||
self.drop_flags.get(&index).map(|t| Place::Base(PlaceBase::Local(*t)))
|
self.drop_flags.get(&index).map(|t| Place::from(*t))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// create a patch that elaborates all drops in the input
|
/// create a patch that elaborates all drops in the input
|
||||||
@ -537,7 +537,7 @@ fn set_drop_flag(&mut self, loc: Location, path: MovePathIndex, val: DropFlagSta
|
|||||||
if let Some(&flag) = self.drop_flags.get(&path) {
|
if let Some(&flag) = self.drop_flags.get(&path) {
|
||||||
let span = self.patch.source_info_for_location(self.body, loc).span;
|
let span = self.patch.source_info_for_location(self.body, loc).span;
|
||||||
let val = self.constant_bool(span, val.value());
|
let val = self.constant_bool(span, val.value());
|
||||||
self.patch.add_assign(loc, Place::Base(PlaceBase::Local(flag)), val);
|
self.patch.add_assign(loc, Place::from(flag), val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -546,7 +546,7 @@ fn drop_flags_on_init(&mut self) {
|
|||||||
let span = self.patch.source_info_for_location(self.body, loc).span;
|
let span = self.patch.source_info_for_location(self.body, loc).span;
|
||||||
let false_ = self.constant_bool(span, false);
|
let false_ = self.constant_bool(span, false);
|
||||||
for flag in self.drop_flags.values() {
|
for flag in self.drop_flags.values() {
|
||||||
self.patch.add_assign(loc, Place::Base(PlaceBase::Local(*flag)), false_.clone());
|
self.patch.add_assign(loc, Place::from(*flag), false_.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ fn make_state(&self, idx: VariantIdx, val: Operand<'tcx>) -> Rvalue<'tcx> {
|
|||||||
|
|
||||||
// Create a Place referencing a generator struct field
|
// Create a Place referencing a generator struct field
|
||||||
fn make_field(&self, variant_index: VariantIdx, idx: usize, ty: Ty<'tcx>) -> Place<'tcx> {
|
fn make_field(&self, variant_index: VariantIdx, idx: usize, ty: Ty<'tcx>) -> Place<'tcx> {
|
||||||
let self_place = Place::Base(PlaceBase::Local(self_arg()));
|
let self_place = Place::from(self_arg());
|
||||||
let base = self_place.downcast_unnamed(variant_index);
|
let base = self_place.downcast_unnamed(variant_index);
|
||||||
let field = Projection {
|
let field = Projection {
|
||||||
base: base,
|
base: base,
|
||||||
@ -211,7 +211,7 @@ fn make_field(&self, variant_index: VariantIdx, idx: usize, ty: Ty<'tcx>) -> Pla
|
|||||||
|
|
||||||
// Create a statement which changes the discriminant
|
// Create a statement which changes the discriminant
|
||||||
fn set_discr(&self, state_disc: VariantIdx, source_info: SourceInfo) -> Statement<'tcx> {
|
fn set_discr(&self, state_disc: VariantIdx, source_info: SourceInfo) -> Statement<'tcx> {
|
||||||
let self_place = Place::Base(PlaceBase::Local(self_arg()));
|
let self_place = Place::from(self_arg());
|
||||||
Statement {
|
Statement {
|
||||||
source_info,
|
source_info,
|
||||||
kind: StatementKind::SetDiscriminant { place: self_place, variant_index: state_disc },
|
kind: StatementKind::SetDiscriminant { place: self_place, variant_index: state_disc },
|
||||||
@ -222,9 +222,9 @@ fn set_discr(&self, state_disc: VariantIdx, source_info: SourceInfo) -> Statemen
|
|||||||
fn get_discr(&self, body: &mut Body<'tcx>) -> (Statement<'tcx>, Place<'tcx>) {
|
fn get_discr(&self, body: &mut Body<'tcx>) -> (Statement<'tcx>, Place<'tcx>) {
|
||||||
let temp_decl = LocalDecl::new_internal(self.tcx.types.isize, body.span);
|
let temp_decl = LocalDecl::new_internal(self.tcx.types.isize, body.span);
|
||||||
let local_decls_len = body.local_decls.push(temp_decl);
|
let local_decls_len = body.local_decls.push(temp_decl);
|
||||||
let temp = Place::Base(PlaceBase::Local(local_decls_len));
|
let temp = Place::from(local_decls_len);
|
||||||
|
|
||||||
let self_place = Place::Base(PlaceBase::Local(self_arg()));
|
let self_place = Place::from(self_arg());
|
||||||
let assign = Statement {
|
let assign = Statement {
|
||||||
source_info: source_info(body),
|
source_info: source_info(body),
|
||||||
kind: StatementKind::Assign(temp.clone(), box Rvalue::Discriminant(self_place)),
|
kind: StatementKind::Assign(temp.clone(), box Rvalue::Discriminant(self_place)),
|
||||||
@ -271,7 +271,7 @@ fn visit_basic_block_data(&mut self,
|
|||||||
let ret_val = match data.terminator().kind {
|
let ret_val = match data.terminator().kind {
|
||||||
TerminatorKind::Return => Some((VariantIdx::new(1),
|
TerminatorKind::Return => Some((VariantIdx::new(1),
|
||||||
None,
|
None,
|
||||||
Operand::Move(Place::Base(PlaceBase::Local(self.new_ret_local))),
|
Operand::Move(Place::from(self.new_ret_local)),
|
||||||
None)),
|
None)),
|
||||||
TerminatorKind::Yield { ref value, resume, drop } => Some((VariantIdx::new(0),
|
TerminatorKind::Yield { ref value, resume, drop } => Some((VariantIdx::new(0),
|
||||||
Some(resume),
|
Some(resume),
|
||||||
@ -840,7 +840,7 @@ fn elaborate_generator_drops<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, body: &mut
|
|||||||
elaborate_drop(
|
elaborate_drop(
|
||||||
&mut elaborator,
|
&mut elaborator,
|
||||||
source_info,
|
source_info,
|
||||||
&Place::Base(PlaceBase::Local(gen)),
|
&Place::from(gen),
|
||||||
(),
|
(),
|
||||||
target,
|
target,
|
||||||
unwind,
|
unwind,
|
||||||
@ -913,7 +913,7 @@ fn create_generator_drop_shim<'tcx>(
|
|||||||
// Alias tracking must know we changed the type
|
// Alias tracking must know we changed the type
|
||||||
body.basic_blocks_mut()[START_BLOCK].statements.insert(0, Statement {
|
body.basic_blocks_mut()[START_BLOCK].statements.insert(0, Statement {
|
||||||
source_info,
|
source_info,
|
||||||
kind: StatementKind::Retag(RetagKind::Raw, Place::Base(PlaceBase::Local(self_arg()))),
|
kind: StatementKind::Retag(RetagKind::Raw, Place::from(self_arg())),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1031,7 +1031,7 @@ fn insert_clean_drop<'tcx>(body: &mut Body<'tcx>) -> BasicBlock {
|
|||||||
// Create a block to destroy an unresumed generators. This can only destroy upvars.
|
// Create a block to destroy an unresumed generators. This can only destroy upvars.
|
||||||
let drop_clean = BasicBlock::new(body.basic_blocks().len());
|
let drop_clean = BasicBlock::new(body.basic_blocks().len());
|
||||||
let term = TerminatorKind::Drop {
|
let term = TerminatorKind::Drop {
|
||||||
location: Place::Base(PlaceBase::Local(self_arg())),
|
location: Place::from(self_arg()),
|
||||||
target: return_block,
|
target: return_block,
|
||||||
unwind: None,
|
unwind: None,
|
||||||
};
|
};
|
||||||
|
@ -467,7 +467,7 @@ fn dest_needs_borrow(place: &Place<'_>) -> bool {
|
|||||||
let temp = LocalDecl::new_temp(ty, callsite.location.span);
|
let temp = LocalDecl::new_temp(ty, callsite.location.span);
|
||||||
|
|
||||||
let tmp = caller_body.local_decls.push(temp);
|
let tmp = caller_body.local_decls.push(temp);
|
||||||
let tmp = Place::Base(PlaceBase::Local(tmp));
|
let tmp = Place::from(tmp);
|
||||||
|
|
||||||
let stmt = Statement {
|
let stmt = Statement {
|
||||||
source_info: callsite.location,
|
source_info: callsite.location,
|
||||||
@ -561,7 +561,7 @@ fn make_call_args(
|
|||||||
let tuple = self.create_temp_if_necessary(args.next().unwrap(), callsite, caller_body);
|
let tuple = self.create_temp_if_necessary(args.next().unwrap(), callsite, caller_body);
|
||||||
assert!(args.next().is_none());
|
assert!(args.next().is_none());
|
||||||
|
|
||||||
let tuple = Place::Base(PlaceBase::Local(tuple));
|
let tuple = Place::from(tuple);
|
||||||
let tuple_tys = if let ty::Tuple(s) = tuple.ty(caller_body, tcx).ty.sty {
|
let tuple_tys = if let ty::Tuple(s) = tuple.ty(caller_body, tcx).ty.sty {
|
||||||
s
|
s
|
||||||
} else {
|
} else {
|
||||||
@ -621,7 +621,7 @@ fn create_temp_if_necessary(
|
|||||||
|
|
||||||
let stmt = Statement {
|
let stmt = Statement {
|
||||||
source_info: callsite.location,
|
source_info: callsite.location,
|
||||||
kind: StatementKind::Assign(Place::Base(PlaceBase::Local(arg_tmp)), box arg),
|
kind: StatementKind::Assign(Place::from(arg_tmp), box arg),
|
||||||
};
|
};
|
||||||
caller_body[callsite.bb].statements.push(stmt);
|
caller_body[callsite.bb].statements.push(stmt);
|
||||||
arg_tmp
|
arg_tmp
|
||||||
|
@ -83,13 +83,13 @@ fn lower_128bit_ops<'tcx>(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
|||||||
block.statements.push(Statement {
|
block.statements.push(Statement {
|
||||||
source_info: source_info,
|
source_info: source_info,
|
||||||
kind: StatementKind::Assign(
|
kind: StatementKind::Assign(
|
||||||
Place::Base(PlaceBase::Local(local)),
|
Place::from(local),
|
||||||
box Rvalue::Cast(
|
box Rvalue::Cast(
|
||||||
CastKind::Misc,
|
CastKind::Misc,
|
||||||
rhs,
|
rhs,
|
||||||
rhs_override_ty.unwrap())),
|
rhs_override_ty.unwrap())),
|
||||||
});
|
});
|
||||||
rhs = Operand::Move(Place::Base(PlaceBase::Local(local)));
|
rhs = Operand::Move(Place::from(local));
|
||||||
}
|
}
|
||||||
|
|
||||||
let call_did = check_lang_item_type(
|
let call_did = check_lang_item_type(
|
||||||
|
@ -182,7 +182,7 @@ fn assign(&mut self, dest: Local, rvalue: Rvalue<'tcx>, span: Span) {
|
|||||||
span,
|
span,
|
||||||
scope: OUTERMOST_SOURCE_SCOPE
|
scope: OUTERMOST_SOURCE_SCOPE
|
||||||
},
|
},
|
||||||
kind: StatementKind::Assign(Place::Base(PlaceBase::Local(dest)), box rvalue)
|
kind: StatementKind::Assign(Place::from(dest), box rvalue)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ fn promote_temp(&mut self, temp: Local) -> Local {
|
|||||||
args,
|
args,
|
||||||
cleanup: None,
|
cleanup: None,
|
||||||
destination: Some(
|
destination: Some(
|
||||||
(Place::Base(PlaceBase::Local(new_temp)), new_target)
|
(Place::from(new_temp), new_target)
|
||||||
),
|
),
|
||||||
from_hir_call,
|
from_hir_call,
|
||||||
},
|
},
|
||||||
|
@ -97,7 +97,7 @@ fn uniform(&mut self,
|
|||||||
let temp = self.patch.new_temp(item_ty, self.body.source_info(location).span);
|
let temp = self.patch.new_temp(item_ty, self.body.source_info(location).span);
|
||||||
self.patch.add_statement(location, StatementKind::StorageLive(temp));
|
self.patch.add_statement(location, StatementKind::StorageLive(temp));
|
||||||
self.patch.add_assign(location,
|
self.patch.add_assign(location,
|
||||||
Place::Base(PlaceBase::Local(temp)),
|
Place::from(temp),
|
||||||
Rvalue::Use(
|
Rvalue::Use(
|
||||||
Operand::Move(
|
Operand::Move(
|
||||||
Place::Projection(box Projection{
|
Place::Projection(box Projection{
|
||||||
@ -115,7 +115,7 @@ fn uniform(&mut self,
|
|||||||
Rvalue::Aggregate(
|
Rvalue::Aggregate(
|
||||||
box AggregateKind::Array(item_ty),
|
box AggregateKind::Array(item_ty),
|
||||||
temps.iter().map(
|
temps.iter().map(
|
||||||
|x| Operand::Move(Place::Base(PlaceBase::Local(*x)))
|
|x| Operand::Move(Place::from(*x))
|
||||||
).collect()
|
).collect()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -486,7 +486,7 @@ fn adt_switch_block(&mut self,
|
|||||||
// discriminant after it is free-ed, because that
|
// discriminant after it is free-ed, because that
|
||||||
// way lies only trouble.
|
// way lies only trouble.
|
||||||
let discr_ty = adt.repr.discr_type().to_ty(self.tcx());
|
let discr_ty = adt.repr.discr_type().to_ty(self.tcx());
|
||||||
let discr = Place::Base(PlaceBase::Local(self.new_temp(discr_ty)));
|
let discr = Place::from(self.new_temp(discr_ty));
|
||||||
let discr_rv = Rvalue::Discriminant(self.place.clone());
|
let discr_rv = Rvalue::Discriminant(self.place.clone());
|
||||||
let switch_block = BasicBlockData {
|
let switch_block = BasicBlockData {
|
||||||
statements: vec![self.assign(&discr, discr_rv)],
|
statements: vec![self.assign(&discr, discr_rv)],
|
||||||
@ -518,11 +518,11 @@ fn destructor_call_block(&mut self, (succ, unwind): (BasicBlock, Unwind)) -> Bas
|
|||||||
mutbl: hir::Mutability::MutMutable
|
mutbl: hir::Mutability::MutMutable
|
||||||
});
|
});
|
||||||
let ref_place = self.new_temp(ref_ty);
|
let ref_place = self.new_temp(ref_ty);
|
||||||
let unit_temp = Place::Base(PlaceBase::Local(self.new_temp(tcx.mk_unit())));
|
let unit_temp = Place::from(self.new_temp(tcx.mk_unit()));
|
||||||
|
|
||||||
let result = BasicBlockData {
|
let result = BasicBlockData {
|
||||||
statements: vec![self.assign(
|
statements: vec![self.assign(
|
||||||
&Place::Base(PlaceBase::Local(ref_place)),
|
&Place::from(ref_place),
|
||||||
Rvalue::Ref(tcx.lifetimes.re_erased,
|
Rvalue::Ref(tcx.lifetimes.re_erased,
|
||||||
BorrowKind::Mut { allow_two_phase_borrow: false },
|
BorrowKind::Mut { allow_two_phase_borrow: false },
|
||||||
self.place.clone())
|
self.place.clone())
|
||||||
@ -531,7 +531,7 @@ fn destructor_call_block(&mut self, (succ, unwind): (BasicBlock, Unwind)) -> Bas
|
|||||||
kind: TerminatorKind::Call {
|
kind: TerminatorKind::Call {
|
||||||
func: Operand::function_handle(tcx, drop_fn.def_id, substs,
|
func: Operand::function_handle(tcx, drop_fn.def_id, substs,
|
||||||
self.source_info.span),
|
self.source_info.span),
|
||||||
args: vec![Operand::Move(Place::Base(PlaceBase::Local(ref_place)))],
|
args: vec![Operand::Move(Place::from(ref_place))],
|
||||||
destination: Some((unit_temp, succ)),
|
destination: Some((unit_temp, succ)),
|
||||||
cleanup: unwind.into_option(),
|
cleanup: unwind.into_option(),
|
||||||
from_hir_call: true,
|
from_hir_call: true,
|
||||||
@ -576,8 +576,8 @@ fn drop_loop(
|
|||||||
ty: ety,
|
ty: ety,
|
||||||
mutbl: hir::Mutability::MutMutable
|
mutbl: hir::Mutability::MutMutable
|
||||||
});
|
});
|
||||||
let ptr = &Place::Base(PlaceBase::Local(self.new_temp(ref_ty)));
|
let ptr = &Place::from(self.new_temp(ref_ty));
|
||||||
let can_go = &Place::Base(PlaceBase::Local(self.new_temp(tcx.types.bool)));
|
let can_go = &Place::from(self.new_temp(tcx.types.bool));
|
||||||
|
|
||||||
let one = self.constant_usize(1);
|
let one = self.constant_usize(1);
|
||||||
let (ptr_next, cur_next) = if ptr_based {
|
let (ptr_next, cur_next) = if ptr_based {
|
||||||
@ -589,19 +589,19 @@ fn drop_loop(
|
|||||||
elem: ProjectionElem::Deref,
|
elem: ProjectionElem::Deref,
|
||||||
}))
|
}))
|
||||||
),
|
),
|
||||||
Rvalue::BinaryOp(BinOp::Offset, move_(&Place::Base(PlaceBase::Local(cur))), one))
|
Rvalue::BinaryOp(BinOp::Offset, move_(&Place::from(cur)), one))
|
||||||
} else {
|
} else {
|
||||||
(Rvalue::Ref(
|
(Rvalue::Ref(
|
||||||
tcx.lifetimes.re_erased,
|
tcx.lifetimes.re_erased,
|
||||||
BorrowKind::Mut { allow_two_phase_borrow: false },
|
BorrowKind::Mut { allow_two_phase_borrow: false },
|
||||||
self.place.clone().index(cur)),
|
self.place.clone().index(cur)),
|
||||||
Rvalue::BinaryOp(BinOp::Add, move_(&Place::Base(PlaceBase::Local(cur))), one))
|
Rvalue::BinaryOp(BinOp::Add, move_(&Place::from(cur)), one))
|
||||||
};
|
};
|
||||||
|
|
||||||
let drop_block = BasicBlockData {
|
let drop_block = BasicBlockData {
|
||||||
statements: vec![
|
statements: vec![
|
||||||
self.assign(ptr, ptr_next),
|
self.assign(ptr, ptr_next),
|
||||||
self.assign(&Place::Base(PlaceBase::Local(cur)), cur_next)
|
self.assign(&Place::from(cur), cur_next)
|
||||||
],
|
],
|
||||||
is_cleanup: unwind.is_cleanup(),
|
is_cleanup: unwind.is_cleanup(),
|
||||||
terminator: Some(Terminator {
|
terminator: Some(Terminator {
|
||||||
@ -615,7 +615,7 @@ fn drop_loop(
|
|||||||
let loop_block = BasicBlockData {
|
let loop_block = BasicBlockData {
|
||||||
statements: vec![
|
statements: vec![
|
||||||
self.assign(can_go, Rvalue::BinaryOp(BinOp::Eq,
|
self.assign(can_go, Rvalue::BinaryOp(BinOp::Eq,
|
||||||
copy(&Place::Base(PlaceBase::Local(cur))),
|
copy(&Place::from(cur)),
|
||||||
copy(length_or_end)))
|
copy(length_or_end)))
|
||||||
],
|
],
|
||||||
is_cleanup: unwind.is_cleanup(),
|
is_cleanup: unwind.is_cleanup(),
|
||||||
@ -665,8 +665,8 @@ fn open_drop_for_array(&mut self, ety: Ty<'tcx>, opt_size: Option<u64>) -> Basic
|
|||||||
|
|
||||||
let move_ = |place: &Place<'tcx>| Operand::Move(place.clone());
|
let move_ = |place: &Place<'tcx>| Operand::Move(place.clone());
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
let elem_size = &Place::Base(PlaceBase::Local(self.new_temp(tcx.types.usize)));
|
let elem_size = &Place::from(self.new_temp(tcx.types.usize));
|
||||||
let len = &Place::Base(PlaceBase::Local(self.new_temp(tcx.types.usize)));
|
let len = &Place::from(self.new_temp(tcx.types.usize));
|
||||||
|
|
||||||
static USIZE_SWITCH_ZERO: &[u128] = &[0];
|
static USIZE_SWITCH_ZERO: &[u128] = &[0];
|
||||||
|
|
||||||
@ -713,8 +713,7 @@ fn drop_loop_pair(
|
|||||||
let length_or_end = if ptr_based {
|
let length_or_end = if ptr_based {
|
||||||
// FIXME check if we want to make it return a `Place` directly
|
// FIXME check if we want to make it return a `Place` directly
|
||||||
// if all use sites want a `Place::Base` anyway.
|
// if all use sites want a `Place::Base` anyway.
|
||||||
let temp = self.new_temp(iter_ty);
|
Place::from(self.new_temp(iter_ty))
|
||||||
Place::Base(PlaceBase::Local(temp))
|
|
||||||
} else {
|
} else {
|
||||||
length.clone()
|
length.clone()
|
||||||
};
|
};
|
||||||
@ -736,10 +735,10 @@ fn drop_loop_pair(
|
|||||||
unwind,
|
unwind,
|
||||||
ptr_based);
|
ptr_based);
|
||||||
|
|
||||||
let cur = Place::Base(PlaceBase::Local(cur));
|
let cur = Place::from(cur);
|
||||||
let drop_block_stmts = if ptr_based {
|
let drop_block_stmts = if ptr_based {
|
||||||
let tmp_ty = tcx.mk_mut_ptr(self.place_ty(self.place));
|
let tmp_ty = tcx.mk_mut_ptr(self.place_ty(self.place));
|
||||||
let tmp = Place::Base(PlaceBase::Local(self.new_temp(tmp_ty)));
|
let tmp = Place::from(self.new_temp(tmp_ty));
|
||||||
// tmp = &mut P;
|
// tmp = &mut P;
|
||||||
// cur = tmp as *mut T;
|
// cur = tmp as *mut T;
|
||||||
// end = Offset(cur, len);
|
// end = Offset(cur, len);
|
||||||
@ -894,7 +893,7 @@ fn unelaborated_free_block(
|
|||||||
unwind: Unwind,
|
unwind: Unwind,
|
||||||
) -> BasicBlock {
|
) -> BasicBlock {
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
let unit_temp = Place::Base(PlaceBase::Local(self.new_temp(tcx.mk_unit())));
|
let unit_temp = Place::from(self.new_temp(tcx.mk_unit()));
|
||||||
let free_func = tcx.require_lang_item(lang_items::BoxFreeFnLangItem);
|
let free_func = tcx.require_lang_item(lang_items::BoxFreeFnLangItem);
|
||||||
let args = adt.variants[VariantIdx::new(0)].fields.iter().enumerate().map(|(i, f)| {
|
let args = adt.variants[VariantIdx::new(0)].fields.iter().enumerate().map(|(i, f)| {
|
||||||
let field = Field::new(i);
|
let field = Field::new(i);
|
||||||
|
@ -153,7 +153,7 @@ fn write_graph_label<'tcx, W: Write>(
|
|||||||
}
|
}
|
||||||
write!(w,
|
write!(w,
|
||||||
"{:?}: {}",
|
"{:?}: {}",
|
||||||
Place::Base(PlaceBase::Local(arg)),
|
Place::from(arg),
|
||||||
escape(&body.local_decls[arg].ty)
|
escape(&body.local_decls[arg].ty)
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
@ -171,10 +171,10 @@ fn write_graph_label<'tcx, W: Write>(
|
|||||||
|
|
||||||
if let Some(name) = decl.name {
|
if let Some(name) = decl.name {
|
||||||
write!(w, r#"{:?}: {}; // {}<br align="left"/>"#,
|
write!(w, r#"{:?}: {}; // {}<br align="left"/>"#,
|
||||||
Place::Base(PlaceBase::Local(local)), escape(&decl.ty), name)?;
|
Place::from(local), escape(&decl.ty), name)?;
|
||||||
} else {
|
} else {
|
||||||
write!(w, r#"{:?}: {};<br align="left"/>"#,
|
write!(w, r#"{:?}: {};<br align="left"/>"#,
|
||||||
Place::Base(PlaceBase::Local(local)), escape(&decl.ty))?;
|
Place::from(local), escape(&decl.ty))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -601,7 +601,7 @@ fn write_mir_sig(
|
|||||||
if i != 0 {
|
if i != 0 {
|
||||||
write!(w, ", ")?;
|
write!(w, ", ")?;
|
||||||
}
|
}
|
||||||
write!(w, "{:?}: {}", Place::Base(PlaceBase::Local(arg)), body.local_decls[arg].ty)?;
|
write!(w, "{:?}: {}", Place::from(arg), body.local_decls[arg].ty)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(w, ") -> {}", body.return_ty())?;
|
write!(w, ") -> {}", body.return_ty())?;
|
||||||
|
Loading…
Reference in New Issue
Block a user