1- use errors:: * ;
1+ use crate :: errors:: * ;
22use reqwest;
33use std:: fs:: { self , File , OpenOptions } ;
44use std:: io:: prelude:: * ;
55use std:: path:: PathBuf ;
66use std:: process:: { Command , Output } ;
7- use tests:: TestCase ;
7+ use crate :: tests:: TestCase ;
88
99static CRATES_ALL : & [ & str ] = & [ "bare-metal = \" 0.2.0\" " , "vcell = \" 0.1.0\" " ] ;
1010static CRATES_MSP430 : & [ & str ] = & [ "msp430 = \" 0.1.0\" " ] ;
@@ -42,7 +42,7 @@ trait CommandHelper {
4242 name : & str ,
4343 stdout : Option < & PathBuf > ,
4444 stderr : Option < & PathBuf > ,
45- previous_processes_stderr : & Vec < PathBuf > ,
45+ previous_processes_stderr : & [ PathBuf ] ,
4646 ) -> Result < ( ) > ;
4747}
4848
@@ -53,7 +53,7 @@ impl CommandHelper for Output {
5353 name : & str ,
5454 stdout : Option < & PathBuf > ,
5555 stderr : Option < & PathBuf > ,
56- previous_processes_stderr : & Vec < PathBuf > ,
56+ previous_processes_stderr : & [ PathBuf ] ,
5757 ) -> Result < ( ) > {
5858 if let Some ( out) = stdout {
5959 let out_payload = String :: from_utf8_lossy ( & self . stdout ) ;
@@ -70,7 +70,7 @@ impl CommandHelper for Output {
7070 ErrorKind :: ProcessFailed ( name. into ( ) ,
7171 stdout. cloned ( ) ,
7272 stderr. cloned ( ) ,
73- previous_processes_stderr. clone ( ) ,
73+ previous_processes_stderr. to_vec ( ) ,
7474 ) . into ( )
7575 ) ;
7676 }
@@ -109,7 +109,7 @@ pub fn test(t: &TestCase, bin_path: &PathBuf, rustfmt_bin_path: Option<&PathBuf>
109109 . arg ( & chip_dir)
110110 . output ( )
111111 . chain_err ( || "Failed to cargo init" ) ?
112- . capture_outputs ( true , "cargo init" , None , None , & vec ! [ ] ) ?;
112+ . capture_outputs ( true , "cargo init" , None , None , & [ ] ) ?;
113113
114114 // Add some crates to the Cargo.toml of our new project
115115 let svd_toml = path_helper_base ( & chip_dir, & [ "Cargo.toml" ] ) ;
@@ -119,7 +119,7 @@ pub fn test(t: &TestCase, bin_path: &PathBuf, rustfmt_bin_path: Option<&PathBuf>
119119 . open ( svd_toml)
120120 . chain_err ( || "Failed to open Cargo.toml for appending" ) ?;
121121
122- use tests:: Architecture :: * ;
122+ use crate :: tests:: Architecture :: * ;
123123 let crates = CRATES_ALL
124124 . iter ( )
125125 . chain ( match & t. arch {
@@ -154,10 +154,10 @@ pub fn test(t: &TestCase, bin_path: &PathBuf, rustfmt_bin_path: Option<&PathBuf>
154154 // If the architecture is cortex-m we move the generated lib.rs file to src/
155155 let lib_rs_file = path_helper_base ( & chip_dir, & [ "src" , "lib.rs" ] ) ;
156156 let svd2rust_err_file = path_helper_base ( & chip_dir, & [ "svd2rust.err.log" ] ) ;
157- let target = match & t. arch {
158- & CortexM => "cortex-m" ,
159- & Msp430 => "msp430" ,
160- & RiscV => "riscv" ,
157+ let target = match t. arch {
158+ CortexM => "cortex-m" ,
159+ Msp430 => "msp430" ,
160+ RiscV => "riscv" ,
161161 } ;
162162 let mut svd2rust_bin = Command :: new ( bin_path) ;
163163 if nightly {
@@ -175,16 +175,13 @@ pub fn test(t: &TestCase, bin_path: &PathBuf, rustfmt_bin_path: Option<&PathBuf>
175175 "svd2rust" ,
176176 if t. arch != CortexM { Some ( & lib_rs_file) } else { None } , // use Option.filter
177177 Some ( & svd2rust_err_file) ,
178- & vec ! [ ] ,
178+ & [ ] ,
179179 ) ?;
180180 process_stderr_paths. push ( svd2rust_err_file) ;
181181
182- match & t. arch {
183- & CortexM => {
184- // TODO: Give error the path to stderr
185- fs:: rename ( path_helper_base ( & chip_dir, & [ "lib.rs" ] ) , & lib_rs_file) . chain_err ( || "While moving lib.rs file" ) ?
186- }
187- _ => ( ) ,
182+ if let CortexM = t. arch {
183+ // TODO: Give error the path to stderr
184+ fs:: rename ( path_helper_base ( & chip_dir, & [ "lib.rs" ] ) , & lib_rs_file) . chain_err ( || "While moving lib.rs file" ) ?
188185 }
189186
190187 let rustfmt_err_file = path_helper_base ( & chip_dir, & [ "rustfmt.err.log" ] ) ;
0 commit comments