14
14
//!
15
15
//! The current style is:
16
16
//!
17
- //! * No trailing whitespace
18
- //! * No tabs
19
- //! * 100-character lines
20
17
//! * Specific module layout:
21
18
//! 1. use directives
22
19
//! 2. typedefs
29
26
//! Things not verified:
30
27
//!
31
28
//! * alignment
32
- //! * 4-space tabs
33
29
//! * leading colons on paths
34
30
35
31
use std:: env;
@@ -69,10 +65,7 @@ fn walk(path: &Path, err: &mut Errors) {
69
65
match & name[ ..] {
70
66
n if !n. ends_with ( ".rs" ) => continue ,
71
67
72
- "dox.rs" |
73
68
"lib.rs" |
74
- "ctypes.rs" |
75
- "libc.rs" |
76
69
"macros.rs" => continue ,
77
70
78
71
_ => { }
@@ -105,26 +98,9 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) {
105
98
let mut state = State :: Start ;
106
99
let mut s_macros = 0 ;
107
100
let mut f_macros = 0 ;
108
- let mut prev_blank = false ;
101
+ let mut in_impl = false ;
109
102
110
103
for ( i, line) in file. lines ( ) . enumerate ( ) {
111
- if line == "" {
112
- if prev_blank {
113
- err. error ( path, i, "double blank line" ) ;
114
- }
115
- prev_blank = true ;
116
- } else {
117
- prev_blank = false ;
118
- }
119
- if line != line. trim_end ( ) {
120
- err. error ( path, i, "trailing whitespace" ) ;
121
- }
122
- if line. contains ( "\t " ) {
123
- err. error ( path, i, "tab character" ) ;
124
- }
125
- if line. len ( ) > 100 && !( line. contains ( "https://" ) || line. contains ( "http://" ) ) {
126
- err. error ( path, i, "line longer than 100 chars" ) ;
127
- }
128
104
if line. contains ( "#[cfg(" ) && line. contains ( ']' ) && !line. contains ( " if " )
129
105
&& !( line. contains ( "target_endian" ) ||
130
106
line. contains ( "target_arch" ) )
@@ -137,6 +113,12 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) {
137
113
if line. contains ( "#[derive(" ) && ( line. contains ( "Copy" ) || line. contains ( "Clone" ) ) {
138
114
err. error ( path, i, "impl ::Copy and ::Clone manually" ) ;
139
115
}
116
+ if line. contains ( "impl" ) {
117
+ in_impl = true ;
118
+ }
119
+ if in_impl && line. starts_with ( '}' ) {
120
+ in_impl = false ;
121
+ }
140
122
141
123
let orig_line = line;
142
124
let line = line. trim_start ( ) ;
@@ -154,7 +136,7 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) {
154
136
}
155
137
} else if line. starts_with ( "const " ) {
156
138
State :: Constants
157
- } else if line. starts_with ( "type " ) {
139
+ } else if line. starts_with ( "type " ) && !in_impl {
158
140
State :: Typedefs
159
141
} else if line. starts_with ( "s! {" ) {
160
142
s_macros += 1 ;
0 commit comments