Rollup merge of #62859 - spastorino:rename-to-as-ref, r=Centril

Place::as_place_ref is now Place::as_ref

r? @oli-obk
This commit is contained in:
Mark Rousskov 2019-07-23 12:51:16 -04:00 committed by GitHub
commit b2155dd747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 93 additions and 93 deletions

View File

@ -1931,7 +1931,7 @@ impl<'tcx> Place<'tcx> {
iterate_over2(place_base, place_projection, &Projections::Empty, op)
}
pub fn as_place_ref(&self) -> PlaceRef<'_, 'tcx> {
pub fn as_ref(&self) -> PlaceRef<'_, 'tcx> {
PlaceRef {
base: &self.base,
projection: &self.projection,

View File

@ -238,7 +238,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
context: PlaceContext,
location: Location) {
debug!("visit_place(place={:?}, context={:?})", place, context);
self.process_place(&place.as_place_ref(), context, location);
self.process_place(&place.as_ref(), context, location);
}
fn visit_local(&mut self,

View File

@ -253,7 +253,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
PassMode::Direct(_) | PassMode::Pair(..) => {
let op =
self.codegen_consume(&mut bx, &mir::Place::RETURN_PLACE.as_place_ref());
self.codegen_consume(&mut bx, &mir::Place::RETURN_PLACE.as_ref());
if let Ref(llval, _, align) = op.val {
bx.load(llval, align)
} else {
@ -314,7 +314,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
return
}
let place = self.codegen_place(&mut bx, &location.as_place_ref());
let place = self.codegen_place(&mut bx, &location.as_ref());
let (args1, args2);
let mut args = if let Some(llextra) = place.llextra {
args2 = [place.llval, llextra];
@ -1171,7 +1171,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
LocalRef::Place(place) => self.codegen_transmute_into(bx, src, place),
LocalRef::UnsizedPlace(_) => bug!("transmute must not involve unsized locals"),
LocalRef::Operand(None) => {
let dst_layout = bx.layout_of(self.monomorphized_place_ty(&dst.as_place_ref()));
let dst_layout = bx.layout_of(self.monomorphized_place_ty(&dst.as_ref()));
assert!(!dst_layout.ty.has_erasable_regions());
let place = PlaceRef::alloca(bx, dst_layout, "transmute_temp");
place.storage_live(bx);
@ -1186,7 +1186,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}
}
} else {
let dst = self.codegen_place(bx, &dst.as_place_ref());
let dst = self.codegen_place(bx, &dst.as_ref());
self.codegen_transmute_into(bx, src, dst);
}
}

View File

@ -462,7 +462,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
match *operand {
mir::Operand::Copy(ref place) |
mir::Operand::Move(ref place) => {
self.codegen_consume(bx, &place.as_place_ref())
self.codegen_consume(bx, &place.as_ref())
}
mir::Operand::Constant(ref constant) => {

View File

@ -355,7 +355,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}
mir::Rvalue::Ref(_, bk, ref place) => {
let cg_place = self.codegen_place(&mut bx, &place.as_place_ref());
let cg_place = self.codegen_place(&mut bx, &place.as_ref());
let ty = cg_place.layout.ty;
@ -446,7 +446,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
mir::Rvalue::Discriminant(ref place) => {
let discr_ty = rvalue.ty(&*self.mir, bx.tcx());
let discr = self.codegen_place(&mut bx, &place.as_place_ref())
let discr = self.codegen_place(&mut bx, &place.as_ref())
.codegen_get_discr(&mut bx, discr_ty);
(bx, OperandRef {
val: OperandValue::Immediate(discr),
@ -527,7 +527,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}
}
// use common size calculation for non zero-sized types
let cg_value = self.codegen_place(bx, &place.as_place_ref());
let cg_value = self.codegen_place(bx, &place.as_ref());
cg_value.len(bx.cx())
}

View File

@ -46,12 +46,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}
}
} else {
let cg_dest = self.codegen_place(&mut bx, &place.as_place_ref());
let cg_dest = self.codegen_place(&mut bx, &place.as_ref());
self.codegen_rvalue(bx, cg_dest, rvalue)
}
}
mir::StatementKind::SetDiscriminant{ref place, variant_index} => {
self.codegen_place(&mut bx, &place.as_place_ref())
self.codegen_place(&mut bx, &place.as_ref())
.codegen_set_discr(&mut bx, variant_index);
bx
}
@ -73,7 +73,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}
mir::StatementKind::InlineAsm(ref asm) => {
let outputs = asm.outputs.iter().map(|output| {
self.codegen_place(&mut bx, &output.as_place_ref())
self.codegen_place(&mut bx, &output.as_ref())
}).collect();
let input_vals = asm.inputs.iter()

View File

@ -139,14 +139,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let is_partial_move = move_site_vec.iter().any(|move_site| {
let move_out = self.move_data.moves[(*move_site).moi];
let moved_place = &self.move_data.move_paths[move_out.path].place;
used_place != moved_place.as_place_ref()
&& used_place.is_prefix_of(moved_place.as_place_ref())
used_place != moved_place.as_ref()
&& used_place.is_prefix_of(moved_place.as_ref())
});
for move_site in &move_site_vec {
let move_out = self.move_data.moves[(*move_site).moi];
let moved_place = &self.move_data.move_paths[move_out.path].place;
let move_spans = self.move_spans(moved_place.as_place_ref(), move_out.source);
let move_spans = self.move_spans(moved_place.as_ref(), move_out.source);
let move_span = move_spans.args_or_use();
let move_msg = if move_spans.for_closure() {
@ -223,7 +223,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let ty = place.ty(self.body, self.infcx.tcx).ty;
let opt_name =
self.describe_place_with_options(place.as_place_ref(), IncludingDowncast(true));
self.describe_place_with_options(place.as_ref(), IncludingDowncast(true));
let note_msg = match opt_name {
Some(ref name) => format!("`{}`", name),
None => "value".to_owned(),
@ -275,11 +275,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
"report_move_out_while_borrowed: location={:?} place={:?} span={:?} borrow={:?}",
location, place, span, borrow
);
let value_msg = match self.describe_place(place.as_place_ref()) {
let value_msg = match self.describe_place(place.as_ref()) {
Some(name) => format!("`{}`", name),
None => "value".to_owned(),
};
let borrow_msg = match self.describe_place(borrow.borrowed_place.as_place_ref()) {
let borrow_msg = match self.describe_place(borrow.borrowed_place.as_ref()) {
Some(name) => format!("`{}`", name),
None => "value".to_owned(),
};
@ -287,12 +287,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let borrow_spans = self.retrieve_borrow_spans(borrow);
let borrow_span = borrow_spans.args_or_use();
let move_spans = self.move_spans(place.as_place_ref(), location);
let move_spans = self.move_spans(place.as_ref(), location);
let span = move_spans.args_or_use();
let mut err = self.cannot_move_when_borrowed(
span,
&self.describe_place(place.as_place_ref()).unwrap_or_else(|| "_".to_owned()),
&self.describe_place(place.as_ref()).unwrap_or_else(|| "_".to_owned()),
);
err.span_label(borrow_span, format!("borrow of {} occurs here", borrow_msg));
err.span_label(span, format!("move out of {} occurs here", value_msg));
@ -326,21 +326,21 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
// Conflicting borrows are reported separately, so only check for move
// captures.
let use_spans = self.move_spans(place.as_place_ref(), location);
let use_spans = self.move_spans(place.as_ref(), location);
let span = use_spans.var_or_use();
let mut err = self.cannot_use_when_mutably_borrowed(
span,
&self.describe_place(place.as_place_ref()).unwrap_or_else(|| "_".to_owned()),
&self.describe_place(place.as_ref()).unwrap_or_else(|| "_".to_owned()),
borrow_span,
&self.describe_place(borrow.borrowed_place.as_place_ref())
&self.describe_place(borrow.borrowed_place.as_ref())
.unwrap_or_else(|| "_".to_owned()),
);
borrow_spans.var_span_label(&mut err, {
let place = &borrow.borrowed_place;
let desc_place =
self.describe_place(place.as_place_ref()).unwrap_or_else(|| "_".to_owned());
self.describe_place(place.as_ref()).unwrap_or_else(|| "_".to_owned());
format!("borrow occurs due to use of `{}`{}", desc_place, borrow_spans.describe())
});
@ -517,7 +517,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
);
} else {
let borrow_place = &issued_borrow.borrowed_place;
let borrow_place_desc = self.describe_place(borrow_place.as_place_ref())
let borrow_place_desc = self.describe_place(borrow_place.as_ref())
.unwrap_or_else(|| "_".to_owned());
issued_spans.var_span_label(
&mut err,
@ -650,8 +650,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
return Some((
describe_base_place,
describe_place(first_borrowed_place.as_place_ref()),
describe_place(second_borrowed_place.as_place_ref()),
describe_place(first_borrowed_place.as_ref()),
describe_place(second_borrowed_place.as_ref()),
union_ty.to_string(),
));
}
@ -666,7 +666,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
// If we didn't find a field access into a union, or both places match, then
// only return the description of the first place.
(
describe_place(first_borrowed_place.as_place_ref()),
describe_place(first_borrowed_place.as_ref()),
"".to_string(),
"".to_string(),
"".to_string(),
@ -697,7 +697,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
);
let drop_span = place_span.1;
let root_place = self.prefixes(borrow.borrowed_place.as_place_ref(), PrefixSet::All)
let root_place = self.prefixes(borrow.borrowed_place.as_ref(), PrefixSet::All)
.last()
.unwrap();
@ -730,13 +730,13 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
}, borrow_span));
if let StorageDeadOrDrop::Destructor(dropped_ty) =
self.classify_drop_access_kind(borrow.borrowed_place.as_place_ref())
self.classify_drop_access_kind(borrow.borrowed_place.as_ref())
{
// If a borrow of path `B` conflicts with drop of `D` (and
// we're not in the uninteresting case where `B` is a
// prefix of `D`), then report this as a more interesting
// destructor conflict.
if !borrow.borrowed_place.as_place_ref().is_prefix_of(place_span.0.as_place_ref()) {
if !borrow.borrowed_place.as_ref().is_prefix_of(place_span.0.as_ref()) {
self.report_borrow_conflicts_with_destructor(
location, borrow, place_span, kind, dropped_ty,
);
@ -744,7 +744,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
}
}
let place_desc = self.describe_place(borrow.borrowed_place.as_place_ref());
let place_desc = self.describe_place(borrow.borrowed_place.as_ref());
let kind_place = kind.filter(|_| place_desc.is_some()).map(|k| (k, place_span.0));
let explanation = self.explain_why_borrow_contains_point(location, &borrow, kind_place);
@ -951,12 +951,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let mut err = self.cannot_borrow_across_destructor(borrow_span);
let what_was_dropped = match self.describe_place(place.as_place_ref()) {
let what_was_dropped = match self.describe_place(place.as_ref()) {
Some(name) => format!("`{}`", name.as_str()),
None => String::from("temporary value"),
};
let label = match self.describe_place(borrow.borrowed_place.as_place_ref()) {
let label = match self.describe_place(borrow.borrowed_place.as_ref()) {
Some(borrowed) => format!(
"here, drop of {D} needs exclusive access to `{B}`, \
because the type `{T}` implements the `Drop` trait",
@ -1127,7 +1127,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
format!("`{}` is borrowed here", place_desc),
)
} else {
let root_place = self.prefixes(borrow.borrowed_place.as_place_ref(),
let root_place = self.prefixes(borrow.borrowed_place.as_ref(),
PrefixSet::All)
.last()
.unwrap();
@ -1390,7 +1390,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let mut err = self.cannot_mutate_in_match_guard(
span,
loan_span,
&self.describe_place(place.as_place_ref()).unwrap_or_else(|| "_".to_owned()),
&self.describe_place(place.as_ref()).unwrap_or_else(|| "_".to_owned()),
"assign",
);
loan_spans.var_span_label(
@ -1406,7 +1406,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let mut err = self.cannot_assign_to_borrowed(
span,
loan_span,
&self.describe_place(place.as_place_ref()).unwrap_or_else(|| "_".to_owned()),
&self.describe_place(place.as_ref()).unwrap_or_else(|| "_".to_owned()),
);
loan_spans.var_span_label(
@ -1466,8 +1466,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
is_user_variable: None,
..
})
| None => (self.describe_place(place.as_place_ref()), assigned_span),
Some(decl) => (self.describe_place(err_place.as_place_ref()), decl.source_info.span),
| None => (self.describe_place(place.as_ref()), assigned_span),
Some(decl) => (self.describe_place(err_place.as_ref()), decl.source_info.span),
};
let mut err = self.cannot_reassign_immutable(

View File

@ -855,7 +855,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
def_id, is_generator, places
);
if let Some((args_span, var_span)) = self.closure_span(
*def_id, Place::from(target).as_place_ref(), places
*def_id, Place::from(target).as_ref(), places
) {
return ClosureUse {
is_generator,
@ -895,7 +895,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
for (upvar, place) in self.infcx.tcx.upvars(def_id)?.values().zip(places) {
match place {
Operand::Copy(place) |
Operand::Move(place) if target_place == place.as_place_ref() => {
Operand::Move(place) if target_place == place.as_ref() => {
debug!("closure_span: found captured local {:?}", place);
return Some((*args_span, upvar.span));
},

View File

@ -560,7 +560,7 @@ impl<'cx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tcx
self.check_if_path_or_subpath_is_moved(
location,
InitializationRequiringAction::Use,
(place.as_place_ref(), span),
(place.as_ref(), span),
flow_state,
);
}
@ -591,7 +591,7 @@ impl<'cx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tcx
self.check_if_path_or_subpath_is_moved(
location,
InitializationRequiringAction::Use,
(output.as_place_ref(), o.span),
(output.as_ref(), o.span),
flow_state,
);
} else {
@ -1154,7 +1154,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
self.check_if_path_or_subpath_is_moved(
location,
InitializationRequiringAction::Update,
(place_span.0.as_place_ref(), place_span.1),
(place_span.0.as_ref(), place_span.1),
flow_state,
);
}
@ -1232,7 +1232,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
self.check_if_path_or_subpath_is_moved(
location,
action,
(place.as_place_ref(), span),
(place.as_ref(), span),
flow_state,
);
}
@ -1260,7 +1260,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
self.check_if_path_or_subpath_is_moved(
location,
InitializationRequiringAction::Use,
(place.as_place_ref(), span),
(place.as_ref(), span),
flow_state,
);
}
@ -1309,7 +1309,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
fn propagate_closure_used_mut_upvar(&mut self, operand: &Operand<'tcx>) {
let propagate_closure_used_mut_place = |this: &mut Self, place: &Place<'tcx>| {
if place.projection.is_some() {
if let Some(field) = this.is_upvar_field_projection(place.as_place_ref()) {
if let Some(field) = this.is_upvar_field_projection(place.as_ref()) {
this.used_mut_upvars.push(field);
}
} else if let PlaceBase::Local(local) = place.base {
@ -1401,7 +1401,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
self.check_if_path_or_subpath_is_moved(
location,
InitializationRequiringAction::Use,
(place.as_place_ref(), span),
(place.as_ref(), span),
flow_state,
);
}
@ -1419,7 +1419,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
self.check_if_path_or_subpath_is_moved(
location,
InitializationRequiringAction::Use,
(place.as_place_ref(), span),
(place.as_ref(), span),
flow_state,
);
}
@ -1437,7 +1437,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
) {
debug!("check_for_invalidation_at_exit({:?})", borrow);
let place = &borrow.borrowed_place;
let root_place = self.prefixes(place.as_place_ref(), PrefixSet::All).last().unwrap();
let root_place = self.prefixes(place.as_ref(), PrefixSet::All).last().unwrap();
// FIXME(nll-rfc#40): do more precise destructor tracking here. For now
// we just know that all locals are dropped at function exit (otherwise

View File

@ -131,7 +131,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
}
}
let move_spans = self.move_spans(original_path.as_place_ref(), location);
let move_spans = self.move_spans(original_path.as_ref(), location);
grouped_errors.push(GroupedMoveError::OtherIllegalMove {
use_spans: move_spans,
original_path,
@ -160,7 +160,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
let from_simple_let = match_place.is_none();
let match_place = match_place.as_ref().unwrap_or(move_from);
match self.move_data.rev_lookup.find(match_place.as_place_ref()) {
match self.move_data.rev_lookup.find(match_place.as_ref()) {
// Error with the match place
LookupResult::Parent(_) => {
for ge in &mut *grouped_errors {
@ -192,7 +192,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
}
// Error with the pattern
LookupResult::Exact(_) => {
let mpi = match self.move_data.rev_lookup.find(move_from.as_place_ref()) {
let mpi = match self.move_data.rev_lookup.find(move_from.as_ref()) {
LookupResult::Parent(Some(mpi)) => mpi,
// move_from should be a projection from match_place.
_ => unreachable!("Probably not unreachable..."),
@ -242,7 +242,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
};
debug!("report: original_path={:?} span={:?}, kind={:?} \
original_path.is_upvar_field_projection={:?}", original_path, span, kind,
self.is_upvar_field_projection(original_path.as_place_ref()));
self.is_upvar_field_projection(original_path.as_ref()));
(
match kind {
IllegalMoveOriginKind::Static => {
@ -277,7 +277,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
span: Span
) -> DiagnosticBuilder<'a> {
let description = if place.projection.is_none() {
format!("static item `{}`", self.describe_place(place.as_place_ref()).unwrap())
format!("static item `{}`", self.describe_place(place.as_ref()).unwrap())
} else {
let mut base_static = &place.projection;
while let Some(box Projection { base: Some(ref proj), .. }) = base_static {
@ -290,7 +290,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
format!(
"`{:?}` as `{:?}` is a static item",
self.describe_place(place.as_place_ref()).unwrap(),
self.describe_place(place.as_ref()).unwrap(),
self.describe_place(base_static).unwrap(),
)
};
@ -308,7 +308,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
// borrow to provide feedback about why this
// was a move rather than a copy.
let ty = deref_target_place.ty(self.body, self.infcx.tcx).ty;
let upvar_field = self.prefixes(move_place.as_place_ref(), PrefixSet::All)
let upvar_field = self.prefixes(move_place.as_ref(), PrefixSet::All)
.find_map(|p| self.is_upvar_field_projection(p));
let deref_base = match deref_target_place.projection {
@ -363,10 +363,10 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
let upvar_name = upvar.name;
let upvar_span = self.infcx.tcx.hir().span(upvar_hir_id);
let place_name = self.describe_place(move_place.as_place_ref()).unwrap();
let place_name = self.describe_place(move_place.as_ref()).unwrap();
let place_description = if self
.is_upvar_field_projection(move_place.as_place_ref())
.is_upvar_field_projection(move_place.as_ref())
.is_some()
{
format!("`{}`, a {}", place_name, capture_description)
@ -393,7 +393,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
_ => {
let source = self.borrowed_content_source(deref_base);
match (
self.describe_place(move_place.as_place_ref()),
self.describe_place(move_place.as_ref()),
source.describe_for_named_place(),
) {
(Some(place_desc), Some(source_desc)) => {
@ -455,7 +455,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
if binds_to.is_empty() {
let place_ty = move_from.ty(self.body, self.infcx.tcx).ty;
let place_desc = match self.describe_place(move_from.as_place_ref()) {
let place_desc = match self.describe_place(move_from.as_ref()) {
Some(desc) => format!("`{}`", desc),
None => format!("value"),
};
@ -483,7 +483,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
GroupedMoveError::OtherIllegalMove { ref original_path, use_spans, .. } => {
let span = use_spans.var_or_use();
let place_ty = original_path.ty(self.body, self.infcx.tcx).ty;
let place_desc = match self.describe_place(original_path.as_place_ref()) {
let place_desc = match self.describe_place(original_path.as_ref()) {
Some(desc) => format!("`{}`", desc),
None => format!("value"),
};

View File

@ -42,7 +42,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
let item_msg;
let reason;
let mut opt_source = None;
let access_place_desc = self.describe_place(access_place.as_place_ref());
let access_place_desc = self.describe_place(access_place.as_ref());
debug!("report_mutability_error: access_place_desc={:?}", access_place_desc);
match the_place_err {
@ -77,7 +77,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
));
item_msg = format!("`{}`", access_place_desc.unwrap());
if self.is_upvar_field_projection(access_place.as_place_ref()).is_some() {
if self.is_upvar_field_projection(access_place.as_ref()).is_some() {
reason = ", as it is not declared as mutable".to_string();
} else {
let name = self.upvars[upvar_index.index()].name;
@ -109,7 +109,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
));
reason =
if self.is_upvar_field_projection(access_place.as_place_ref()).is_some() {
if self.is_upvar_field_projection(access_place.as_ref()).is_some() {
", as it is a captured variable in a `Fn` closure".to_string()
} else {
", as `Fn` closures cannot mutate their captured variables".to_string()
@ -244,7 +244,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
format!(
"mutable borrow occurs due to use of `{}` in closure",
// always Some() if the message is printed.
self.describe_place(access_place.as_place_ref()).unwrap_or_default(),
self.describe_place(access_place.as_ref()).unwrap_or_default(),
)
);
borrow_span

View File

@ -252,7 +252,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
Some(Cause::LiveVar(local, location)) => {
let span = body.source_info(location).span;
let spans = self
.move_spans(Place::from(local).as_place_ref(), location)
.move_spans(Place::from(local).as_ref(), location)
.or_else(|| self.borrow_spans(span, location));
let borrow_location = location;
@ -305,7 +305,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
);
if let Some(region_name) = region_name {
let opt_place_desc =
self.describe_place(borrow.borrowed_place.as_place_ref());
self.describe_place(borrow.borrowed_place.as_ref());
BorrowExplanation::MustBeValidFor {
category,
from_closure,

View File

@ -50,7 +50,7 @@ pub(super) fn each_borrow_involving_path<'tcx, F, I, S>(
body,
&borrowed.borrowed_place,
borrowed.kind,
place.as_place_ref(),
place.as_ref(),
access,
places_conflict::PlaceConflictBias::Overlap,
) {

View File

@ -36,7 +36,7 @@ crate fn places_conflict<'tcx>(
body,
borrow_place,
BorrowKind::Mut { allow_two_phase_borrow: true },
access_place.as_place_ref(),
access_place.as_ref(),
AccessDepth::Deep,
bias,
)

View File

@ -1304,7 +1304,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
prefix_cursor = base;
}
all_fake_borrows.push(place.as_place_ref());
all_fake_borrows.push(place.as_ref());
}
// Deduplicate and ensure a deterministic order.

View File

@ -171,7 +171,7 @@ pub(crate) fn drop_flag_effects_for_function_entry<'tcx, F>(
let move_data = &ctxt.move_data;
for arg in body.args_iter() {
let place = mir::Place::from(arg);
let lookup_result = move_data.rev_lookup.find(place.as_place_ref());
let lookup_result = move_data.rev_lookup.find(place.as_ref());
on_lookup_result_bits(tcx, body, move_data,
lookup_result,
|mpi| callback(mpi, DropFlagState::Present));

View File

@ -309,7 +309,7 @@ impl<'a, 'tcx> BitDenotation<'tcx> for MaybeInitializedPlaces<'a, 'tcx> {
// when a call returns successfully, that means we need to set
// the bits for that dest_place to 1 (initialized).
on_lookup_result_bits(self.tcx, self.body, self.move_data(),
self.move_data().rev_lookup.find(dest_place.as_place_ref()),
self.move_data().rev_lookup.find(dest_place.as_ref()),
|mpi| { in_out.insert(mpi); });
}
}
@ -367,7 +367,7 @@ impl<'a, 'tcx> BitDenotation<'tcx> for MaybeUninitializedPlaces<'a, 'tcx> {
// when a call returns successfully, that means we need to set
// the bits for that dest_place to 0 (initialized).
on_lookup_result_bits(self.tcx, self.body, self.move_data(),
self.move_data().rev_lookup.find(dest_place.as_place_ref()),
self.move_data().rev_lookup.find(dest_place.as_ref()),
|mpi| { in_out.remove(mpi); });
}
}
@ -423,7 +423,7 @@ impl<'a, 'tcx> BitDenotation<'tcx> for DefinitelyInitializedPlaces<'a, 'tcx> {
// when a call returns successfully, that means we need to set
// the bits for that dest_place to 1 (initialized).
on_lookup_result_bits(self.tcx, self.body, self.move_data(),
self.move_data().rev_lookup.find(dest_place.as_place_ref()),
self.move_data().rev_lookup.find(dest_place.as_ref()),
|mpi| { in_out.insert(mpi); });
}
}

View File

@ -274,9 +274,9 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
// move-path for the interior so it will be separate from
// the exterior.
self.create_move_path(&place.clone().deref());
self.gather_init(place.as_place_ref(), InitKind::Shallow);
self.gather_init(place.as_ref(), InitKind::Shallow);
} else {
self.gather_init(place.as_place_ref(), InitKind::Deep);
self.gather_init(place.as_ref(), InitKind::Deep);
}
self.gather_rvalue(rval);
}
@ -286,7 +286,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
StatementKind::InlineAsm(ref asm) => {
for (output, kind) in asm.outputs.iter().zip(&asm.asm.outputs) {
if !kind.is_indirect {
self.gather_init(output.as_place_ref(), InitKind::Deep);
self.gather_init(output.as_ref(), InitKind::Deep);
}
}
for (_, input) in asm.inputs.iter() {
@ -376,7 +376,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
TerminatorKind::DropAndReplace { ref location, ref value, .. } => {
self.create_move_path(location);
self.gather_operand(value);
self.gather_init(location.as_place_ref(), InitKind::Deep);
self.gather_init(location.as_ref(), InitKind::Deep);
}
TerminatorKind::Call {
ref func,
@ -391,7 +391,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
}
if let Some((ref destination, _bb)) = *destination {
self.create_move_path(destination);
self.gather_init(destination.as_place_ref(), InitKind::NonPanicPathOnly);
self.gather_init(destination.as_ref(), InitKind::NonPanicPathOnly);
}
}
}

View File

@ -79,7 +79,7 @@ impl MirPass for AddRetag {
let needs_retag = |place: &Place<'tcx>| {
// FIXME: Instead of giving up for unstable places, we should introduce
// a temporary and retag on that.
is_stable(place.as_place_ref())
is_stable(place.as_ref())
&& may_have_reference(place.ty(&*local_decls, tcx).ty, tcx)
};

View File

@ -105,7 +105,7 @@ fn find_dead_unwinds<'tcx>(
init_data.apply_location(tcx, body, env, loc);
}
let path = match env.move_data.rev_lookup.find(location.as_place_ref()) {
let path = match env.move_data.rev_lookup.find(location.as_ref()) {
LookupResult::Exact(e) => e,
LookupResult::Parent(..) => {
debug!("find_dead_unwinds: has parent; skipping");
@ -360,7 +360,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
statement_index: data.statements.len()
});
let path = self.move_data().rev_lookup.find(location.as_place_ref());
let path = self.move_data().rev_lookup.find(location.as_ref());
debug!("collect_drop_flags: {:?}, place {:?} ({:?})",
bb, location, path);
@ -399,7 +399,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
match terminator.kind {
TerminatorKind::Drop { ref location, target, unwind } => {
let init_data = self.initialization_data_at(loc);
match self.move_data().rev_lookup.find(location.as_place_ref()) {
match self.move_data().rev_lookup.find(location.as_ref()) {
LookupResult::Exact(path) => {
elaborate_drop(
&mut Elaborator {
@ -488,7 +488,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
is_cleanup: false,
});
match self.move_data().rev_lookup.find(location.as_place_ref()) {
match self.move_data().rev_lookup.find(location.as_ref()) {
LookupResult::Exact(path) => {
debug!("elaborate_drop_and_replace({:?}) - tracked {:?}", terminator, path);
let init_data = self.initialization_data_at(loc);
@ -558,7 +558,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
assert!(!self.patch.is_patched(bb));
let loc = Location { block: tgt, statement_index: 0 };
let path = self.move_data().rev_lookup.find(place.as_place_ref());
let path = self.move_data().rev_lookup.find(place.as_ref());
on_lookup_result_bits(
self.tcx, self.body, self.move_data(), path,
|child| self.set_drop_flag(loc, child, DropFlagState::Present)
@ -632,7 +632,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
assert!(!self.patch.is_patched(bb));
let loc = Location { block: bb, statement_index: data.statements.len() };
let path = self.move_data().rev_lookup.find(place.as_place_ref());
let path = self.move_data().rev_lookup.find(place.as_ref());
on_lookup_result_bits(
self.tcx, self.body, self.move_data(), path,
|child| self.set_drop_flag(loc, child, DropFlagState::Present)

View File

@ -243,7 +243,7 @@ trait Qualif {
fn in_operand(cx: &ConstCx<'_, 'tcx>, operand: &Operand<'tcx>) -> bool {
match *operand {
Operand::Copy(ref place) |
Operand::Move(ref place) => Self::in_place(cx, place.as_place_ref()),
Operand::Move(ref place) => Self::in_place(cx, place.as_ref()),
Operand::Constant(ref constant) => {
if let ConstValue::Unevaluated(def_id, _) = constant.literal.val {
@ -272,7 +272,7 @@ trait Qualif {
Rvalue::NullaryOp(..) => false,
Rvalue::Discriminant(ref place) |
Rvalue::Len(ref place) => Self::in_place(cx, place.as_place_ref()),
Rvalue::Len(ref place) => Self::in_place(cx, place.as_ref()),
Rvalue::Use(ref operand) |
Rvalue::Repeat(ref operand, _) |
@ -298,7 +298,7 @@ trait Qualif {
}
}
Self::in_place(cx, place.as_place_ref())
Self::in_place(cx, place.as_ref())
}
Rvalue::Aggregate(_, ref operands) => {

View File

@ -168,7 +168,7 @@ fn each_block<'tcx, O>(
if place == peek_arg_place {
if let mir::Rvalue::Ref(_, mir::BorrowKind::Shared, ref peeking_at_place) = **rvalue {
// Okay, our search is over.
match move_data.rev_lookup.find(peeking_at_place.as_place_ref()) {
match move_data.rev_lookup.find(peeking_at_place.as_ref()) {
LookupResult::Exact(peek_mpi) => {
let bit_state = on_entry.contains(peek_mpi);
debug!("rustc_peek({:?} = &{:?}) bit_state: {}",
@ -192,7 +192,7 @@ fn each_block<'tcx, O>(
}
}
let lhs_mpi = move_data.rev_lookup.find(place.as_place_ref());
let lhs_mpi = move_data.rev_lookup.find(place.as_ref());
debug!("rustc_peek: computing effect on place: {:?} ({:?}) in stmt: {:?}",
place, lhs_mpi, stmt);