diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2020-03-01 20:21:09 +0100 |
|---|---|---|
| committer | Matthias Krüger <matthias.krueger@famsik.de> | 2020-03-01 21:17:48 +0100 |
| commit | 22339c340615d6c8ad6a05bf4ff339113c19d968 (patch) | |
| tree | 9a9ff960a680a17039eb704c264a80db6510a6a6 | |
| parent | 03aecda83ad54098266e9e44cc04e0b37c3cf47a (diff) | |
| download | rust-22339c340615d6c8ad6a05bf4ff339113c19d968.tar.gz rust-22339c340615d6c8ad6a05bf4ff339113c19d968.zip | |
use for (idx, item) in iter.enumerate() instead of manually counting loop iterations by variables
| -rw-r--r-- | src/librustc/ty/layout.rs | 6 | ||||
| -rw-r--r-- | src/librustc_errors/emitter.rs | 5 |
2 files changed, 4 insertions, 7 deletions
diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index e10c0241435..641f904ae69 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -1382,10 +1382,8 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { // Write down the order of our locals that will be promoted to the prefix. { - let mut idx = 0u32; - for local in ineligible_locals.iter() { - assignments[local] = Ineligible(Some(idx)); - idx += 1; + for (idx, local) in ineligible_locals.iter().enumerate() { + assignments[local] = Ineligible(Some(idx as u32)); } } debug!("generator saved local assignments: {:?}", assignments); diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 2d7ff191c77..eb9d4b887ad 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -1574,9 +1574,9 @@ impl EmitterWriter { let line_start = sm.lookup_char_pos(parts[0].span.lo()).line; draw_col_separator_no_space(&mut buffer, 1, max_line_num_len + 1); - let mut line_pos = 0; let mut lines = complete.lines(); - for line in lines.by_ref().take(MAX_SUGGESTION_HIGHLIGHT_LINES) { + for (line_pos, line) in lines.by_ref().take(MAX_SUGGESTION_HIGHLIGHT_LINES).enumerate() + { // Print the span column to avoid confusion buffer.puts( row_num, @@ -1587,7 +1587,6 @@ impl EmitterWriter { // print the suggestion draw_col_separator(&mut buffer, row_num, max_line_num_len + 1); buffer.append(row_num, line, Style::NoStyle); - line_pos += 1; row_num += 1; } |
