Skip to content

Commit

Permalink
Avoid cloning Place in is_stable
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Jul 20, 2019
1 parent 17a465c commit 7b456df
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/librustc_mir/transform/add_retag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct AddRetag;
/// (Concurrent accesses by other threads are no problem as these are anyway non-atomic
/// copies. Data races are UB.)
fn is_stable(
place: &Place<'_>,
place: PlaceRef<'_, '_>,
) -> bool {
if let Some(proj) = &place.projection {
match proj.elem {
Expand All @@ -32,9 +32,9 @@ fn is_stable(
ProjectionElem::ConstantIndex { .. } |
ProjectionElem::Subslice { .. } |
ProjectionElem::Downcast { .. } =>
is_stable(&Place {
base: place.base.clone(),
projection: proj.base.clone(),
is_stable(PlaceRef {
base: place.base,
projection: &proj.base,
}),
}
} else {
Expand Down Expand Up @@ -79,7 +79,8 @@ 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) && may_have_reference(place.ty(&*local_decls, tcx).ty, tcx)
is_stable(place.as_place_ref())
&& may_have_reference(place.ty(&*local_decls, tcx).ty, tcx)
};

// PART 1
Expand Down

0 comments on commit 7b456df

Please sign in to comment.