Skip to content

Commit

Permalink
XXX: debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Oct 25, 2023
1 parent ad56628 commit a03aadc
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/tools/tidy/src/alphabetical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,19 @@ const END_MARKER: &str = "tidy-alphabetical-end";

fn check_section<'a>(
file: impl Display,
lines: impl Iterator<Item = (usize, &'a str)>,
mut lines: impl Iterator<Item = (usize, &'a str)>,
bad: &mut bool,
) {
let mut prev_line = String::new();
let mut first_indent = None;
let mut in_split_line = None;
let mut pm1 = None;
let mut pm2 = None;
let mut pm3 = None;

loop {
let Some((line_idx, line)) = lines.next() else { break };

for (line_idx, line) in lines {
if line.is_empty() {
continue;
}
Expand Down Expand Up @@ -91,9 +96,20 @@ fn check_section<'a>(

if trimmed_line.to_lowercase() < prev_line_trimmed_lowercase {
tidy_error!(bad, "{file}:{}: line not in alphabetical order", line_idx + 1,);
tidy_error!(bad, "{file}: line-3: `{:?}", pm3);
tidy_error!(bad, "{file}: line-2: `{:?}", pm2);
tidy_error!(bad, "{file}: line-1: `{:?}", pm1);
tidy_error!(bad, "{file}: line0: `{}", line);
tidy_error!(bad, "{file}: line1: `{:?}", lines.next());
tidy_error!(bad, "{file}: line2: `{:?}", lines.next());
tidy_error!(bad, "{file}: line3: `{:?}", lines.next());
}

prev_line = line;
prev_line = line.clone();

pm3 = pm2;
pm2 = pm1;
pm1 = Some(line);
}

tidy_error!(bad, "{file}: reached end of file expecting `{END_MARKER}`")
Expand Down

0 comments on commit a03aadc

Please sign in to comment.