Skip to content

Commit 6b6580c

Browse files
committed
Auto merge of #4540 - jolson88:fix-place-projection, r=phansch
Fix rustc breaking change: convert to Place's new boxed slice projection Addressed breaking changes from rust-lang PR rust-lang/rust#63420 I'm not entirely sure the semantics are preserved as I don't have much knowledge about MIR yet. So this code was largely reverse-engineered from the PR above. I wouldn't be surprised if I did something wrong :). I followed the instructions to pull latest rustc from master and verified the build break I was seeing in my PR for cast-lossless in Travis CI. With these changes, it compiles again and all tests pass. Fixes rust-lang/rust#64440 changelog: none
2 parents ff4a3fb + 80822b4 commit 6b6580c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

clippy_lints/src/redundant_clone.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,13 @@ fn find_stmt_assigns_to<'a, 'tcx: 'a>(
252252
stmts
253253
.rev()
254254
.find_map(|stmt| {
255-
if let mir::StatementKind::Assign(
255+
if let mir::StatementKind::Assign(box (
256256
mir::Place {
257257
base: mir::PlaceBase::Local(local),
258258
..
259259
},
260260
v,
261-
) = &stmt.kind
261+
)) = &stmt.kind
262262
{
263263
if *local == to {
264264
return Some(v);
@@ -269,10 +269,10 @@ fn find_stmt_assigns_to<'a, 'tcx: 'a>(
269269
})
270270
.and_then(|v| {
271271
if by_ref {
272-
if let mir::Rvalue::Ref(_, _, ref place) = **v {
272+
if let mir::Rvalue::Ref(_, _, ref place) = v {
273273
return base_local_and_movability(cx, mir, place);
274274
}
275-
} else if let mir::Rvalue::Use(mir::Operand::Copy(ref place)) = **v {
275+
} else if let mir::Rvalue::Use(mir::Operand::Copy(ref place)) = v {
276276
return base_local_and_movability(cx, mir, place);
277277
}
278278
None
@@ -291,7 +291,6 @@ fn base_local_and_movability<'tcx>(
291291
use rustc::mir::Place;
292292
use rustc::mir::PlaceBase;
293293
use rustc::mir::PlaceRef;
294-
use rustc::mir::Projection;
295294

296295
// Dereference. You cannot move things out from a borrowed value.
297296
let mut deref = false;
@@ -303,7 +302,7 @@ fn base_local_and_movability<'tcx>(
303302
mut projection,
304303
} = place.as_ref();
305304
if let PlaceBase::Local(local) = place_base {
306-
while let Some(box Projection { base, elem }) = projection {
305+
while let [base @ .., elem] = projection {
307306
projection = base;
308307
deref = matches!(elem, mir::ProjectionElem::Deref);
309308
field = !field

0 commit comments

Comments
 (0)