Skip to content

Commit 6641223

Browse files
committed
clean clippy warning
1 parent 9eea6db commit 6641223

6 files changed

Lines changed: 1000 additions & 998 deletions

File tree

‎crates/cpp_code_analysis/tests/publication_revision.rs‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,6 @@ fn background_waves_defer_open_files_without_starving_other_work() {
167167
let wave = session.prepare_background_wave(2);
168168
assert!(wave.prepared.iter().all(|(path, _)| path != &open));
169169
let (done, _) = session.commit_a_wave(wave, 2);
170-
// **The commit no longer stalls on that deferred file.** It used to break out of its loop when the head was an
171-
// open document the wave had deferred — and `prepare_wave` defers open documents, so the head was never popped
172-
// and the pump prepared the same wave for ever (`d344ba0e`: 17 rounds a second, one core, ~90 MB/s on
173-
// `containers.cpp`). `index_one` builds the summary itself, so the queue moves; what must not happen is the wave
174-
// *parsing* the open file's rendering, and the assertion above pins that.
175170
assert!(
176171
done.iter().any(|step| step.path == open),
177172
"the deferred open file is worked by the commit rather than left at the head: {done:?}"

‎crates/cpp_formatter/src/breaks.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,11 @@ mod break_tests {
462462
let mut start = line.start;
463463
for at in breaks.iter().copied().chain(std::iter::once(line.end)) {
464464
let mut text = String::new();
465-
for index in start..at {
466-
if index > start {
465+
for (offset, token) in stream.tokens[start..at].iter().enumerate() {
466+
if offset > 0 {
467467
text.push(' ');
468468
}
469-
text.push_str(stream.tokens[index].text);
469+
text.push_str(token.text);
470470
}
471471
pieces.push(text);
472472
start = at;

‎crates/cpp_formatter/src/layout.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,13 +343,13 @@ fn matching_angle(stream: &Stream<'_>, open: usize) -> Option<usize> {
343343
return Option::None;
344344
}
345345
let mut depth = 0isize;
346-
for cursor in open..stream.tokens.len() {
347-
match stream.tokens[cursor].kind {
346+
for (offset, token) in stream.tokens[open..].iter().enumerate() {
347+
match token.kind {
348348
Less => depth += 1,
349349
Greater => {
350350
depth -= 1;
351351
if depth == 0 {
352-
return Option::Some(cursor);
352+
return Option::Some(open + offset);
353353
}
354354
}
355355
Semicolon | LeftBrace | RightBrace | RightParen => return Option::None,

‎crates/cpp_formatter/src/rows.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,9 @@ fn align_run(
136136
}
137137
let mut cells: Vec<Vec<usize>> = vec![Vec::new()];
138138
let mut depth = 0isize;
139-
for index in row.open + 1..row.close {
140-
match stream.tokens[index].kind {
139+
for (offset, token) in stream.tokens[row.open + 1..row.close].iter().enumerate() {
140+
let index = row.open + 1 + offset;
141+
match token.kind {
141142
CppTokenKind::LeftBrace | CppTokenKind::LeftParen | CppTokenKind::LeftBracket => {
142143
depth += 1
143144
}

‎crates/cpp_formatter/src/trailing.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ pub fn columns(source: &str, stream: &Stream<'_>, style: &Style) -> Vec<Option<u
2727
// The line each trailing comment sits on, and where its code ends.
2828
let mut found: Vec<(usize, usize, usize)> = Vec::new(); // (line, gap index, code end column)
2929
let mut line = 0usize;
30-
for index in 0..stream.gaps.len() {
31-
line += stream.gaps[index].newlines;
32-
let Some(comment) = stream.gaps[index].comments.last() else {
30+
for (index, gap) in stream.gaps.iter().enumerate() {
31+
line += gap.newlines;
32+
let Some(comment) = gap.comments.last() else {
3333
continue;
3434
};
3535
if comment.own_line {

0 commit comments

Comments
 (0)