Avoid cloning Place in report_cannot_move_from_borrowed_content
This commit is contained in:
parent
09014fc793
commit
10470797a6
3 changed files with 12 additions and 12 deletions
|
@ -481,14 +481,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
|
||||
pub(super) fn borrowed_content_source(
|
||||
&self,
|
||||
deref_base: &Place<'tcx>,
|
||||
deref_base: PlaceRef<'cx, 'tcx>,
|
||||
) -> BorrowedContentSource<'tcx> {
|
||||
let tcx = self.infcx.tcx;
|
||||
|
||||
// Look up the provided place and work out the move path index for it,
|
||||
// we'll use this to check whether it was originally from an overloaded
|
||||
// operator.
|
||||
match self.move_data.rev_lookup.find(deref_base.as_place_ref()) {
|
||||
match self.move_data.rev_lookup.find(deref_base) {
|
||||
LookupResult::Exact(mpi) | LookupResult::Parent(Some(mpi)) => {
|
||||
debug!("borrowed_content_source: mpi={:?}", mpi);
|
||||
|
||||
|
@ -533,7 +533,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
|
||||
// If we didn't find an overloaded deref or index, then assume it's a
|
||||
// built in deref and check the type of the base.
|
||||
let base_ty = deref_base.ty(self.body, tcx).ty;
|
||||
let base_ty = Place::ty_from(deref_base.base, deref_base.projection, self.body, tcx).ty;
|
||||
if base_ty.is_unsafe_ptr() {
|
||||
BorrowedContentSource::DerefRawPointer
|
||||
} else if base_ty.is_mutable_pointer() {
|
||||
|
|
|
@ -312,18 +312,18 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
.find_map(|p| self.is_upvar_field_projection(p));
|
||||
|
||||
let deref_base = match deref_target_place.projection {
|
||||
Some(box Projection { ref base, elem: ProjectionElem::Deref }) => Place {
|
||||
base: deref_target_place.base.clone(),
|
||||
projection: base.clone(),
|
||||
Some(box Projection { ref base, elem: ProjectionElem::Deref }) => PlaceRef {
|
||||
base: &deref_target_place.base,
|
||||
projection: base,
|
||||
},
|
||||
_ => bug!("deref_target_place is not a deref projection"),
|
||||
};
|
||||
|
||||
if let Place {
|
||||
if let PlaceRef {
|
||||
base: PlaceBase::Local(local),
|
||||
projection: None,
|
||||
} = deref_base {
|
||||
let decl = &self.body.local_decls[local];
|
||||
let decl = &self.body.local_decls[*local];
|
||||
if decl.is_ref_for_guard() {
|
||||
let mut err = self.cannot_move_out_of(
|
||||
span,
|
||||
|
@ -391,7 +391,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
diag
|
||||
}
|
||||
_ => {
|
||||
let source = self.borrowed_content_source(&deref_base);
|
||||
let source = self.borrowed_content_source(deref_base);
|
||||
match (
|
||||
self.describe_place(move_place.as_place_ref()),
|
||||
source.describe_for_named_place(),
|
||||
|
|
|
@ -124,9 +124,9 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
item_msg = format!("`{}`", access_place_desc.unwrap());
|
||||
reason = ", as it is immutable for the pattern guard".to_string();
|
||||
} else {
|
||||
let source = self.borrowed_content_source(&Place {
|
||||
base: the_place_err.base.clone(),
|
||||
projection: base.clone(),
|
||||
let source = self.borrowed_content_source(PlaceRef {
|
||||
base: the_place_err.base,
|
||||
projection: base,
|
||||
});
|
||||
let pointer_type = source.describe_for_immutable_place();
|
||||
opt_source = Some(source);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue