Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rustc breaking change: convert to Place's new boxed slice projection #4540

Merged
merged 1 commit into from
Sep 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions clippy_lints/src/redundant_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,13 @@ fn find_stmt_assigns_to<'a, 'tcx: 'a>(
stmts
.rev()
.find_map(|stmt| {
if let mir::StatementKind::Assign(
if let mir::StatementKind::Assign(box (
mir::Place {
base: mir::PlaceBase::Local(local),
..
},
v,
) = &stmt.kind
)) = &stmt.kind
{
if *local == to {
return Some(v);
Expand All @@ -269,10 +269,10 @@ fn find_stmt_assigns_to<'a, 'tcx: 'a>(
})
.and_then(|v| {
if by_ref {
if let mir::Rvalue::Ref(_, _, ref place) = **v {
if let mir::Rvalue::Ref(_, _, ref place) = v {
return base_local_and_movability(cx, mir, place);
}
} else if let mir::Rvalue::Use(mir::Operand::Copy(ref place)) = **v {
} else if let mir::Rvalue::Use(mir::Operand::Copy(ref place)) = v {
return base_local_and_movability(cx, mir, place);
}
None
Expand All @@ -291,7 +291,6 @@ fn base_local_and_movability<'tcx>(
use rustc::mir::Place;
use rustc::mir::PlaceBase;
use rustc::mir::PlaceRef;
use rustc::mir::Projection;

// Dereference. You cannot move things out from a borrowed value.
let mut deref = false;
Expand All @@ -303,7 +302,7 @@ fn base_local_and_movability<'tcx>(
mut projection,
} = place.as_ref();
if let PlaceBase::Local(local) = place_base {
while let Some(box Projection { base, elem }) = projection {
while let [base @ .., elem] = projection {
projection = base;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoa! 🤯

deref = matches!(elem, mir::ProjectionElem::Deref);
field = !field
Expand Down