Skip to content

Commit

Permalink
Place::as_place_ref is now Place::as_ref
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Jul 21, 2019
1 parent 83dfe7b commit 795d96d
Show file tree
Hide file tree
Showing 22 changed files with 93 additions and 93 deletions.
2 changes: 1 addition & 1 deletion src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/mir/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_codegen_ssa/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/mir/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_codegen_ssa/mir/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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())
}

Expand Down
6 changes: 3 additions & 3 deletions src/librustc_codegen_ssa/mir/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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()
Expand Down
54 changes: 27 additions & 27 deletions src/librustc_mir/borrow_check/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -275,24 +275,24 @@ 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(),
};

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));
Expand Down Expand Up @@ -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())
});
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
));
}
Expand All @@ -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(),
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -730,21 +730,21 @@ 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,
);
return;
}
}

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);
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/borrow_check/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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));
},
Expand Down
Loading

0 comments on commit 795d96d

Please sign in to comment.