@@ -67,10 +67,9 @@ pub fn load_props(testfile: &Path) -> TestProps {
6767 let mut pretty_compare_only = false ;
6868 let mut forbid_output = Vec :: new ( ) ;
6969 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+ }
7473
7574 if compile_flags. is_none ( ) {
7675 compile_flags = parse_compile_flags ( ln) ;
@@ -108,24 +107,20 @@ pub fn load_props(testfile: &Path) -> TestProps {
108107 pretty_compare_only = parse_pretty_compare_only ( ln) ;
109108 }
110109
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) ;
114112 }
115113
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) ;
119116 }
120117
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+ }
125121
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) ;
129124 }
130125
131126 true
@@ -134,8 +129,8 @@ pub fn load_props(testfile: &Path) -> TestProps {
134129 for key in vec ! [ "RUST_TEST_NOCAPTURE" , "RUST_TEST_THREADS" ] {
135130 match env:: var ( key) {
136131 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) )
139134 } ,
140135 Err ( ..) => { }
141136 }
@@ -153,7 +148,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
153148 check_stdout : check_stdout,
154149 no_prefer_dynamic : no_prefer_dynamic,
155150 pretty_expanded : pretty_expanded,
156- pretty_mode : pretty_mode. unwrap_or ( "normal" . to_string ( ) ) ,
151+ pretty_mode : pretty_mode. unwrap_or ( "normal" . to_owned ( ) ) ,
157152 pretty_compare_only : pretty_compare_only,
158153 forbid_output : forbid_output,
159154 }
@@ -182,22 +177,21 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
182177 return true ;
183178 }
184179
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
199192 }
200- None => false
193+ } else {
194+ false
201195 }
202196 }
203197
@@ -210,22 +204,21 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
210204 return true ;
211205 }
212206
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
227219 }
228- None => false
220+ } else {
221+ false
229222 }
230223 }
231224
@@ -316,11 +309,11 @@ fn parse_exec_env(line: &str) -> Option<(String, String)> {
316309 // nv is either FOO or FOO=BAR
317310 let mut strs: Vec < String > = nv
318311 . splitn ( 2 , '=' )
319- . map ( |s| s . to_string ( ) )
312+ . map ( str :: to_owned )
320313 . collect ( ) ;
321314
322315 match strs. len ( ) {
323- 1 => ( strs. pop ( ) . unwrap ( ) , "" . to_string ( ) ) ,
316+ 1 => ( strs. pop ( ) . unwrap ( ) , "" . to_owned ( ) ) ,
324317 2 => {
325318 let end = strs. pop ( ) . unwrap ( ) ;
326319 ( strs. pop ( ) . unwrap ( ) , end)
@@ -331,33 +324,31 @@ fn parse_exec_env(line: &str) -> Option<(String, String)> {
331324}
332325
333326fn 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 {
337330 if parse_name_directive ( line, "pp-exact" ) {
338- testfile. file_name ( ) . map ( |s| PathBuf :: from ( s ) )
331+ testfile. file_name ( ) . map ( PathBuf :: from)
339332 } else {
340333 None
341334 }
342- }
343335 }
344336}
345337
346338fn parse_name_directive ( line : & str , directive : & str ) -> bool {
347339 // 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) )
349341}
350342
351343pub fn parse_name_value_directive ( line : & str , directive : & str )
352344 -> Option < String > {
353345 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
361352 }
362353}
363354
0 commit comments