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

Rustup "Remove BodyAndCache" #5508

Merged
merged 2 commits into from
Apr 23, 2020
Merged
Changes from 1 commit
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
7 changes: 3 additions & 4 deletions clippy_lints/src/redundant_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
}

let mir = cx.tcx.optimized_mir(def_id.to_def_id());
let mir_read_only = mir.unwrap_read_only();

let maybe_storage_live_result = MaybeStorageLive
.into_engine(cx.tcx, mir, def_id.to_def_id())
.iterate_to_fixpoint()
.into_results_cursor(mir);
let mut possible_borrower = {
let mut vis = PossibleBorrowerVisitor::new(cx, mir);
vis.visit_body(&mir_read_only);
vis.visit_body(&mir);
vis.into_map(cx, maybe_storage_live_result)
};

Expand Down Expand Up @@ -146,7 +145,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
// `arg` is a reference as it is `.deref()`ed in the previous block.
// Look into the predecessor block and find out the source of deref.

let ps = mir_read_only.predecessors_for(bb);
let ps = mir.predecessors_for(bb);
tesuji marked this conversation as resolved.
Show resolved Hide resolved
if ps.len() != 1 {
continue;
}
Expand Down Expand Up @@ -191,7 +190,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
(local, deref_clone_ret)
};

let is_temp = mir_read_only.local_kind(ret_local) == mir::LocalKind::Temp;
let is_temp = mir.local_kind(ret_local) == mir::LocalKind::Temp;

// 1. `local` can be moved out if it is not used later.
// 2. If `ret_local` is a temporary and is neither consumed nor mutated, we can remove this `clone`
Expand Down