Skip to content

Commit 7b456df

Browse files
committed
Avoid cloning Place in is_stable
1 parent 17a465c commit 7b456df

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/librustc_mir/transform/add_retag.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct AddRetag;
1515
/// (Concurrent accesses by other threads are no problem as these are anyway non-atomic
1616
/// copies. Data races are UB.)
1717
fn is_stable(
18-
place: &Place<'_>,
18+
place: PlaceRef<'_, '_>,
1919
) -> bool {
2020
if let Some(proj) = &place.projection {
2121
match proj.elem {
@@ -32,9 +32,9 @@ fn is_stable(
3232
ProjectionElem::ConstantIndex { .. } |
3333
ProjectionElem::Subslice { .. } |
3434
ProjectionElem::Downcast { .. } =>
35-
is_stable(&Place {
36-
base: place.base.clone(),
37-
projection: proj.base.clone(),
35+
is_stable(PlaceRef {
36+
base: place.base,
37+
projection: &proj.base,
3838
}),
3939
}
4040
} else {
@@ -79,7 +79,8 @@ impl MirPass for AddRetag {
7979
let needs_retag = |place: &Place<'tcx>| {
8080
// FIXME: Instead of giving up for unstable places, we should introduce
8181
// a temporary and retag on that.
82-
is_stable(place) && may_have_reference(place.ty(&*local_decls, tcx).ty, tcx)
82+
is_stable(place.as_place_ref())
83+
&& may_have_reference(place.ty(&*local_decls, tcx).ty, tcx)
8384
};
8485

8586
// PART 1

0 commit comments

Comments
 (0)