@@ -34,10 +34,12 @@ use std::io::prelude::*;
34
34
use std:: path:: Path ;
35
35
36
36
macro_rules! t {
37
- ( $e: expr) => ( match $e {
38
- Ok ( e) => e,
39
- Err ( e) => panic!( "{} failed with {}" , stringify!( $e) , e) ,
40
- } )
37
+ ( $e: expr) => {
38
+ match $e {
39
+ Ok ( e) => e,
40
+ Err ( e) => panic!( "{} failed with {}" , stringify!( $e) , e) ,
41
+ }
42
+ } ;
41
43
}
42
44
43
45
fn main ( ) {
@@ -58,15 +60,14 @@ fn walk(path: &Path, err: &mut Errors) {
58
60
let path = entry. path ( ) ;
59
61
if t ! ( entry. file_type( ) ) . is_dir ( ) {
60
62
walk ( & path, err) ;
61
- continue
63
+ continue ;
62
64
}
63
65
64
66
let name = entry. file_name ( ) . into_string ( ) . unwrap ( ) ;
65
67
match & name[ ..] {
66
68
n if !n. ends_with ( ".rs" ) => continue ,
67
69
68
- "lib.rs" |
69
- "macros.rs" => continue ,
70
+ "lib.rs" | "macros.rs" => continue ,
70
71
71
72
_ => { }
72
73
}
@@ -101,13 +102,13 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) {
101
102
let mut in_impl = false ;
102
103
103
104
for ( i, line) in file. lines ( ) . enumerate ( ) {
104
- if line. contains ( "#[cfg(" ) && line. contains ( ']' ) && !line. contains ( " if " )
105
- && !( line. contains ( "target_endian" ) ||
106
- line. contains ( "target_arch" ) )
105
+ if line. contains ( "#[cfg(" )
106
+ && line. contains ( ']' )
107
+ && !line. contains ( " if " )
108
+ && !( line. contains ( "target_endian" ) || line. contains ( "target_arch" ) )
107
109
{
108
110
if state != State :: Structs {
109
- err. error ( path, i, "use cfg_if! and submodules \
110
- instead of #[cfg]") ;
111
+ err. error ( path, i, "use cfg_if! and submodules instead of #[cfg]" ) ;
111
112
}
112
113
}
113
114
if line. contains ( "#[derive(" ) && ( line. contains ( "Copy" ) || line. contains ( "Clone" ) ) {
@@ -123,7 +124,7 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) {
123
124
let orig_line = line;
124
125
let line = line. trim_start ( ) ;
125
126
let is_pub = line. starts_with ( "pub " ) ;
126
- let line = if is_pub { & line[ 4 ..] } else { line} ;
127
+ let line = if is_pub { & line[ 4 ..] } else { line } ;
127
128
128
129
let line_state = if line. starts_with ( "use " ) {
129
130
if line. contains ( "c_void" ) {
@@ -149,13 +150,19 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) {
149
150
} else if line. starts_with ( "mod " ) {
150
151
State :: Modules
151
152
} else {
152
- continue
153
+ continue ;
153
154
} ;
154
155
155
156
if state as usize > line_state as usize {
156
- err. error ( path, i, & format ! ( "{} found after {} when \
157
- it belongs before",
158
- line_state. desc( ) , state. desc( ) ) ) ;
157
+ err. error (
158
+ path,
159
+ i,
160
+ & format ! (
161
+ "{} found after {} when it belongs before" ,
162
+ line_state. desc( ) ,
163
+ state. desc( )
164
+ ) ,
165
+ ) ;
159
166
}
160
167
161
168
if f_macros == 2 {
0 commit comments