@@ -36,14 +36,19 @@ const END_MARKER: &str = "tidy-alphabetical-end";
36
36
37
37
fn check_section < ' a > (
38
38
file : impl Display ,
39
- lines : impl Iterator < Item = ( usize , & ' a str ) > ,
39
+ mut lines : impl Iterator < Item = ( usize , & ' a str ) > ,
40
40
bad : & mut bool ,
41
41
) {
42
42
let mut prev_line = String :: new ( ) ;
43
43
let mut first_indent = None ;
44
44
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 } ;
45
51
46
- for ( line_idx, line) in lines {
47
52
if line. is_empty ( ) {
48
53
continue ;
49
54
}
@@ -91,9 +96,20 @@ fn check_section<'a>(
91
96
92
97
if trimmed_line. to_lowercase ( ) < prev_line_trimmed_lowercase {
93
98
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( ) ) ;
94
106
}
95
107
96
- prev_line = line;
108
+ prev_line = line. clone ( ) ;
109
+
110
+ pm3 = pm2;
111
+ pm2 = pm1;
112
+ pm1 = Some ( line) ;
97
113
}
98
114
99
115
tidy_error ! ( bad, "{file}: reached end of file expecting `{END_MARKER}`" )
0 commit comments