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