Rollup merge of #97079 - SparrowLii:successors, r=lcnr

Change `Successors` to `impl Iterator<Item = BasicBlock>`

This PR fixes the FIXME in `compiler\rustc_middle\src\mir\mod.rs`.
This can omit several `&`, `*` or `cloned` operations on Successros' generated elements
This commit is contained in:
Yuki Okushi 2022-05-17 19:01:32 +09:00 committed by GitHub
commit ae9d727b8d

View file

@ -114,7 +114,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClone {
}
// Give up on loops
if terminator.successors().any(|s| *s == bb) {
if terminator.successors().any(|s| s == bb) {
continue;
}
@ -440,7 +440,7 @@ fn visit_clone_usage(cloned: mir::Local, clone: mir::Local, mir: &mir::Body<'_>,
// Short-circuit
if (usage.cloned_used && usage.clone_consumed_or_mutated) ||
// Give up on loops
tdata.terminator().successors().any(|s| *s == bb)
tdata.terminator().successors().any(|s| s == bb)
{
return CloneUsage {
cloned_used: true,