use for (idx, item) in iter.enumerate() instead of manually counting loop iterations by variables

This commit is contained in:
Matthias Krüger 2020-03-01 20:21:09 +01:00
parent 03aecda83a
commit 22339c3406
2 changed files with 4 additions and 7 deletions

View File

@ -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);

View File

@ -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;
}