diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2021-02-12 22:53:38 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-12 22:53:38 +0100 |
| commit | 1ef566fc7c72a5e15ffd54334c744b6638b24374 (patch) | |
| tree | c971608c75fc98dd65787e909375c93744b563da | |
| parent | 54013fe59e7dc8667226eda4855516335dd1094c (diff) | |
| parent | fde59a8cb73f87ced306a29649b80c3776bab526 (diff) | |
| download | rust-1ef566fc7c72a5e15ffd54334c744b6638b24374.tar.gz rust-1ef566fc7c72a5e15ffd54334c744b6638b24374.zip | |
Rollup merge of #82030 - LingMan:init_directly, r=varkor
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.
| -rw-r--r-- | compiler/rustc_typeck/src/check/upvar.rs | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs index 4f90f2877ed..75cad9f21c9 100644 --- a/compiler/rustc_typeck/src/check/upvar.rs +++ b/compiler/rustc_typeck/src/check/upvar.rs @@ -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 |
