@@ -36,14 +36,19 @@ const END_MARKER: &str = "tidy-alphabetical-end";
3636
3737fn check_section < ' a > (
3838 file : impl Display ,
39- lines : impl Iterator < Item = ( usize , & ' a str ) > ,
39+ mut lines : impl Iterator < Item = ( usize , & ' a str ) > ,
4040 bad : & mut bool ,
4141) {
4242 let mut prev_line = String :: new ( ) ;
4343 let mut first_indent = None ;
4444 let mut in_split_line = None ;
45+ let mut pm1 = None ;
46+ let mut pm2 = None ;
47+ let mut pm3 = None ;
48+
49+ loop {
50+ let Some ( ( line_idx, line) ) = lines. next ( ) else { break } ;
4551
46- for ( line_idx, line) in lines {
4752 if line. is_empty ( ) {
4853 continue ;
4954 }
@@ -91,9 +96,20 @@ fn check_section<'a>(
9196
9297 if trimmed_line. to_lowercase ( ) < prev_line_trimmed_lowercase {
9398 tidy_error ! ( bad, "{file}:{}: line not in alphabetical order" , line_idx + 1 , ) ;
99+ tidy_error ! ( bad, "{file}: line-3: `{:?}" , pm3) ;
100+ tidy_error ! ( bad, "{file}: line-2: `{:?}" , pm2) ;
101+ tidy_error ! ( bad, "{file}: line-1: `{:?}" , pm1) ;
102+ tidy_error ! ( bad, "{file}: line0: `{}" , line) ;
103+ tidy_error ! ( bad, "{file}: line1: `{:?}" , lines. next( ) ) ;
104+ tidy_error ! ( bad, "{file}: line2: `{:?}" , lines. next( ) ) ;
105+ tidy_error ! ( bad, "{file}: line3: `{:?}" , lines. next( ) ) ;
94106 }
95107
96- prev_line = line;
108+ prev_line = line. clone ( ) ;
109+
110+ pm3 = pm2;
111+ pm2 = pm1;
112+ pm1 = Some ( line) ;
97113 }
98114
99115 tidy_error ! ( bad, "{file}: reached end of file expecting `{END_MARKER}`" )
0 commit comments