Skip to content

Commit

Permalink
Rollup merge of #82030 - LingMan:init_directly, r=varkor
Browse files Browse the repository at this point in the history
Use `Iterator::all` instead of open-coding it

Shorter code and by initializing to the final value directly, the variable
doesn't need to be mut.
  • Loading branch information
Dylan-DPC committed Feb 12, 2021
2 parents 3db4afd + fde59a8 commit 3c50257
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions compiler/rustc_typeck/src/check/upvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1382,14 +1382,8 @@ fn determine_place_ancestry_relation(
// Assume of length of projections_b = m
let projections_b = &place_b.projections;

let mut same_initial_projections = true;

for (proj_a, proj_b) in projections_a.iter().zip(projections_b.iter()) {
if proj_a != proj_b {
same_initial_projections = false;
break;
}
}
let same_initial_projections =
projections_a.iter().zip(projections_b.iter()).all(|(proj_a, proj_b)| proj_a == proj_b);

if same_initial_projections {
// First min(n, m) projections are the same
Expand Down

0 comments on commit 3c50257

Please sign in to comment.