@@ -67,10 +67,9 @@ pub fn load_props(testfile: &Path) -> TestProps {
67
67
let mut pretty_compare_only = false ;
68
68
let mut forbid_output = Vec :: new ( ) ;
69
69
iter_header ( testfile, & mut |ln| {
70
- match parse_error_pattern ( ln) {
71
- Some ( ep) => error_patterns. push ( ep) ,
72
- None => ( )
73
- } ;
70
+ if let Some ( ep) = parse_error_pattern ( ln) {
71
+ error_patterns. push ( ep) ;
72
+ }
74
73
75
74
if compile_flags. is_none ( ) {
76
75
compile_flags = parse_compile_flags ( ln) ;
@@ -108,24 +107,20 @@ pub fn load_props(testfile: &Path) -> TestProps {
108
107
pretty_compare_only = parse_pretty_compare_only ( ln) ;
109
108
}
110
109
111
- match parse_aux_build ( ln) {
112
- Some ( ab) => { aux_builds. push ( ab) ; }
113
- None => { }
110
+ if let Some ( ab) = parse_aux_build ( ln) {
111
+ aux_builds. push ( ab) ;
114
112
}
115
113
116
- match parse_exec_env ( ln) {
117
- Some ( ee) => { exec_env. push ( ee) ; }
118
- None => { }
114
+ if let Some ( ee) = parse_exec_env ( ln) {
115
+ exec_env. push ( ee) ;
119
116
}
120
117
121
- match parse_check_line ( ln) {
122
- Some ( cl) => check_lines. push ( cl) ,
123
- None => ( )
124
- } ;
118
+ if let Some ( cl) = parse_check_line ( ln) {
119
+ check_lines. push ( cl) ;
120
+ }
125
121
126
- match parse_forbid_output ( ln) {
127
- Some ( of) => forbid_output. push ( of) ,
128
- None => ( ) ,
122
+ if let Some ( of) = parse_forbid_output ( ln) {
123
+ forbid_output. push ( of) ;
129
124
}
130
125
131
126
true
@@ -134,8 +129,8 @@ pub fn load_props(testfile: &Path) -> TestProps {
134
129
for key in vec ! [ "RUST_TEST_NOCAPTURE" , "RUST_TEST_THREADS" ] {
135
130
match env:: var ( key) {
136
131
Ok ( val) =>
137
- if exec_env. iter ( ) . find ( |& & ( ref x, _) | * x == key. to_string ( ) ) . is_none ( ) {
138
- exec_env. push ( ( key. to_string ( ) , val) )
132
+ if exec_env. iter ( ) . find ( |& & ( ref x, _) | * x == key) . is_none ( ) {
133
+ exec_env. push ( ( key. to_owned ( ) , val) )
139
134
} ,
140
135
Err ( ..) => { }
141
136
}
@@ -153,7 +148,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
153
148
check_stdout : check_stdout,
154
149
no_prefer_dynamic : no_prefer_dynamic,
155
150
pretty_expanded : pretty_expanded,
156
- pretty_mode : pretty_mode. unwrap_or ( "normal" . to_string ( ) ) ,
151
+ pretty_mode : pretty_mode. unwrap_or ( "normal" . to_owned ( ) ) ,
157
152
pretty_compare_only : pretty_compare_only,
158
153
forbid_output : forbid_output,
159
154
}
@@ -182,22 +177,21 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
182
177
return true ;
183
178
}
184
179
185
- match config. gdb_version {
186
- Some ( ref actual_version) => {
187
- if line. contains ( "min-gdb-version" ) {
188
- let min_version = line. trim ( )
189
- . split ( ' ' )
190
- . last ( )
191
- . expect ( "Malformed GDB version directive" ) ;
192
- // Ignore if actual version is smaller the minimum required
193
- // version
194
- gdb_version_to_int ( actual_version) <
195
- gdb_version_to_int ( min_version)
196
- } else {
197
- false
198
- }
180
+ if let Some ( ref actual_version) = config. gdb_version {
181
+ if line. contains ( "min-gdb-version" ) {
182
+ let min_version = line. trim ( )
183
+ . split ( ' ' )
184
+ . last ( )
185
+ . expect ( "Malformed GDB version directive" ) ;
186
+ // Ignore if actual version is smaller the minimum required
187
+ // version
188
+ gdb_version_to_int ( actual_version) <
189
+ gdb_version_to_int ( min_version)
190
+ } else {
191
+ false
199
192
}
200
- None => false
193
+ } else {
194
+ false
201
195
}
202
196
}
203
197
@@ -210,22 +204,21 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
210
204
return true ;
211
205
}
212
206
213
- match config. lldb_version {
214
- Some ( ref actual_version) => {
215
- if line. contains ( "min-lldb-version" ) {
216
- let min_version = line. trim ( )
217
- . split ( ' ' )
218
- . last ( )
219
- . expect ( "Malformed lldb version directive" ) ;
220
- // Ignore if actual version is smaller the minimum required
221
- // version
222
- lldb_version_to_int ( actual_version) <
223
- lldb_version_to_int ( min_version)
224
- } else {
225
- false
226
- }
207
+ if let Some ( ref actual_version) = config. lldb_version {
208
+ if line. contains ( "min-lldb-version" ) {
209
+ let min_version = line. trim ( )
210
+ . split ( ' ' )
211
+ . last ( )
212
+ . expect ( "Malformed lldb version directive" ) ;
213
+ // Ignore if actual version is smaller the minimum required
214
+ // version
215
+ lldb_version_to_int ( actual_version) <
216
+ lldb_version_to_int ( min_version)
217
+ } else {
218
+ false
227
219
}
228
- None => false
220
+ } else {
221
+ false
229
222
}
230
223
}
231
224
@@ -316,11 +309,11 @@ fn parse_exec_env(line: &str) -> Option<(String, String)> {
316
309
// nv is either FOO or FOO=BAR
317
310
let mut strs: Vec < String > = nv
318
311
. splitn ( 2 , '=' )
319
- . map ( |s| s . to_string ( ) )
312
+ . map ( str :: to_owned )
320
313
. collect ( ) ;
321
314
322
315
match strs. len ( ) {
323
- 1 => ( strs. pop ( ) . unwrap ( ) , "" . to_string ( ) ) ,
316
+ 1 => ( strs. pop ( ) . unwrap ( ) , "" . to_owned ( ) ) ,
324
317
2 => {
325
318
let end = strs. pop ( ) . unwrap ( ) ;
326
319
( strs. pop ( ) . unwrap ( ) , end)
@@ -331,33 +324,31 @@ fn parse_exec_env(line: &str) -> Option<(String, String)> {
331
324
}
332
325
333
326
fn parse_pp_exact ( line : & str , testfile : & Path ) -> Option < PathBuf > {
334
- match parse_name_value_directive ( line, "pp-exact" ) {
335
- Some ( s ) => Some ( PathBuf :: from ( & s) ) ,
336
- None => {
327
+ if let Some ( s ) = parse_name_value_directive ( line, "pp-exact" ) {
328
+ Some ( PathBuf :: from ( & s) )
329
+ } else {
337
330
if parse_name_directive ( line, "pp-exact" ) {
338
- testfile. file_name ( ) . map ( |s| PathBuf :: from ( s ) )
331
+ testfile. file_name ( ) . map ( PathBuf :: from)
339
332
} else {
340
333
None
341
334
}
342
- }
343
335
}
344
336
}
345
337
346
338
fn parse_name_directive ( line : & str , directive : & str ) -> bool {
347
339
// This 'no-' rule is a quick hack to allow pretty-expanded and no-pretty-expanded to coexist
348
- line. contains ( directive) && !line. contains ( & ( "no-" . to_string ( ) + directive) )
340
+ line. contains ( directive) && !line. contains ( & ( "no-" . to_owned ( ) + directive) )
349
341
}
350
342
351
343
pub fn parse_name_value_directive ( line : & str , directive : & str )
352
344
-> Option < String > {
353
345
let keycolon = format ! ( "{}:" , directive) ;
354
- match line. find ( & keycolon) {
355
- Some ( colon) => {
356
- let value = line[ ( colon + keycolon. len ( ) ) .. line. len ( ) ] . to_string ( ) ;
357
- debug ! ( "{}: {}" , directive, value) ;
358
- Some ( value)
359
- }
360
- None => None
346
+ if let Some ( colon) = line. find ( & keycolon) {
347
+ let value = line[ ( colon + keycolon. len ( ) ) .. line. len ( ) ] . to_owned ( ) ;
348
+ debug ! ( "{}: {}" , directive, value) ;
349
+ Some ( value)
350
+ } else {
351
+ None
361
352
}
362
353
}
363
354
0 commit comments