Skip to content

Commit 22339c3

Browse files
committed
use for (idx, item) in iter.enumerate() instead of manually counting loop iterations by variables
1 parent 03aecda commit 22339c3

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/librustc/ty/layout.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1382,10 +1382,8 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
13821382

13831383
// Write down the order of our locals that will be promoted to the prefix.
13841384
{
1385-
let mut idx = 0u32;
1386-
for local in ineligible_locals.iter() {
1387-
assignments[local] = Ineligible(Some(idx));
1388-
idx += 1;
1385+
for (idx, local) in ineligible_locals.iter().enumerate() {
1386+
assignments[local] = Ineligible(Some(idx as u32));
13891387
}
13901388
}
13911389
debug!("generator saved local assignments: {:?}", assignments);

src/librustc_errors/emitter.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1574,9 +1574,9 @@ impl EmitterWriter {
15741574

15751575
let line_start = sm.lookup_char_pos(parts[0].span.lo()).line;
15761576
draw_col_separator_no_space(&mut buffer, 1, max_line_num_len + 1);
1577-
let mut line_pos = 0;
15781577
let mut lines = complete.lines();
1579-
for line in lines.by_ref().take(MAX_SUGGESTION_HIGHLIGHT_LINES) {
1578+
for (line_pos, line) in lines.by_ref().take(MAX_SUGGESTION_HIGHLIGHT_LINES).enumerate()
1579+
{
15801580
// Print the span column to avoid confusion
15811581
buffer.puts(
15821582
row_num,
@@ -1587,7 +1587,6 @@ impl EmitterWriter {
15871587
// print the suggestion
15881588
draw_col_separator(&mut buffer, row_num, max_line_num_len + 1);
15891589
buffer.append(row_num, line, Style::NoStyle);
1590-
line_pos += 1;
15911590
row_num += 1;
15921591
}
15931592

0 commit comments

Comments
 (0)