1
- use errors:: * ;
1
+ use crate :: errors:: * ;
2
2
use reqwest;
3
3
use std:: fs:: { self , File , OpenOptions } ;
4
4
use std:: io:: prelude:: * ;
5
5
use std:: path:: PathBuf ;
6
6
use std:: process:: { Command , Output } ;
7
- use tests:: TestCase ;
7
+ use crate :: tests:: TestCase ;
8
8
9
9
static CRATES_ALL : & [ & str ] = & [ "bare-metal = \" 0.2.0\" " , "vcell = \" 0.1.0\" " ] ;
10
10
static CRATES_MSP430 : & [ & str ] = & [ "msp430 = \" 0.1.0\" " ] ;
@@ -42,7 +42,7 @@ trait CommandHelper {
42
42
name : & str ,
43
43
stdout : Option < & PathBuf > ,
44
44
stderr : Option < & PathBuf > ,
45
- previous_processes_stderr : & Vec < PathBuf > ,
45
+ previous_processes_stderr : & [ PathBuf ] ,
46
46
) -> Result < ( ) > ;
47
47
}
48
48
@@ -53,7 +53,7 @@ impl CommandHelper for Output {
53
53
name : & str ,
54
54
stdout : Option < & PathBuf > ,
55
55
stderr : Option < & PathBuf > ,
56
- previous_processes_stderr : & Vec < PathBuf > ,
56
+ previous_processes_stderr : & [ PathBuf ] ,
57
57
) -> Result < ( ) > {
58
58
if let Some ( out) = stdout {
59
59
let out_payload = String :: from_utf8_lossy ( & self . stdout ) ;
@@ -70,7 +70,7 @@ impl CommandHelper for Output {
70
70
ErrorKind :: ProcessFailed ( name. into ( ) ,
71
71
stdout. cloned ( ) ,
72
72
stderr. cloned ( ) ,
73
- previous_processes_stderr. clone ( ) ,
73
+ previous_processes_stderr. to_vec ( ) ,
74
74
) . into ( )
75
75
) ;
76
76
}
@@ -109,7 +109,7 @@ pub fn test(t: &TestCase, bin_path: &PathBuf, rustfmt_bin_path: Option<&PathBuf>
109
109
. arg ( & chip_dir)
110
110
. output ( )
111
111
. chain_err ( || "Failed to cargo init" ) ?
112
- . capture_outputs ( true , "cargo init" , None , None , & vec ! [ ] ) ?;
112
+ . capture_outputs ( true , "cargo init" , None , None , & [ ] ) ?;
113
113
114
114
// Add some crates to the Cargo.toml of our new project
115
115
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>
119
119
. open ( svd_toml)
120
120
. chain_err ( || "Failed to open Cargo.toml for appending" ) ?;
121
121
122
- use tests:: Architecture :: * ;
122
+ use crate :: tests:: Architecture :: * ;
123
123
let crates = CRATES_ALL
124
124
. iter ( )
125
125
. chain ( match & t. arch {
@@ -154,10 +154,10 @@ pub fn test(t: &TestCase, bin_path: &PathBuf, rustfmt_bin_path: Option<&PathBuf>
154
154
// If the architecture is cortex-m we move the generated lib.rs file to src/
155
155
let lib_rs_file = path_helper_base ( & chip_dir, & [ "src" , "lib.rs" ] ) ;
156
156
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" ,
161
161
} ;
162
162
let mut svd2rust_bin = Command :: new ( bin_path) ;
163
163
if nightly {
@@ -175,16 +175,13 @@ pub fn test(t: &TestCase, bin_path: &PathBuf, rustfmt_bin_path: Option<&PathBuf>
175
175
"svd2rust" ,
176
176
if t. arch != CortexM { Some ( & lib_rs_file) } else { None } , // use Option.filter
177
177
Some ( & svd2rust_err_file) ,
178
- & vec ! [ ] ,
178
+ & [ ] ,
179
179
) ?;
180
180
process_stderr_paths. push ( svd2rust_err_file) ;
181
181
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" ) ?
188
185
}
189
186
190
187
let rustfmt_err_file = path_helper_base ( & chip_dir, & [ "rustfmt.err.log" ] ) ;
0 commit comments