From a03aadcd82b1ac4d5723b2b2247bab95aed69e65 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 25 Oct 2023 11:24:42 +1100 Subject: [PATCH] XXX: debugging --- src/tools/tidy/src/alphabetical.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/tools/tidy/src/alphabetical.rs b/src/tools/tidy/src/alphabetical.rs index 98a8f4a998019..e798fe9b7bf61 100644 --- a/src/tools/tidy/src/alphabetical.rs +++ b/src/tools/tidy/src/alphabetical.rs @@ -36,14 +36,19 @@ const END_MARKER: &str = "tidy-alphabetical-end"; fn check_section<'a>( file: impl Display, - lines: impl Iterator, + mut lines: impl Iterator, 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; } @@ -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}`")