File tree 1 file changed +7
-0
lines changed
1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ pub fn check(path: &Path, bad: &mut bool) {
112
112
let skip_length = contents. contains ( "ignore-tidy-linelength" ) ;
113
113
let skip_end_whitespace = contents. contains ( "ignore-tidy-end-whitespace" ) ;
114
114
let skip_copyright = contents. contains ( "ignore-tidy-copyright" ) ;
115
+ let mut leading_new_lines = false ;
115
116
let mut trailing_new_lines = 0 ;
116
117
for ( i, line) in contents. split ( '\n' ) . enumerate ( ) {
117
118
let mut err = |msg : & str | {
@@ -152,11 +153,17 @@ pub fn check(path: &Path, bad: &mut bool) {
152
153
err ( LLVM_UNREACHABLE_INFO ) ;
153
154
}
154
155
if line. is_empty ( ) {
156
+ if i == 0 {
157
+ leading_new_lines = true ;
158
+ }
155
159
trailing_new_lines += 1 ;
156
160
} else {
157
161
trailing_new_lines = 0 ;
158
162
}
159
163
}
164
+ if leading_new_lines {
165
+ tidy_error ! ( bad, "{}: leading newline" , file. display( ) ) ;
166
+ }
160
167
match trailing_new_lines {
161
168
0 => tidy_error ! ( bad, "{}: missing trailing newline" , file. display( ) ) ,
162
169
1 | 2 => { }
You can’t perform that action at this time.
0 commit comments