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