@@ -50,43 +50,68 @@ fn main() {
5050 let test = std:: env:: args ( ) . nth ( 2 ) . map_or ( false , |text| text == "test" ) ;
5151 let skip = if test { 3 } else { 2 } ;
5252
53- let manifest_path_arg = std:: env:: args ( ) . skip ( skip) . find ( |val| val. starts_with ( "--manifest-path=" ) ) ;
54-
55- let mut metadata = if let Ok ( metadata) = cargo_metadata:: metadata ( manifest_path_arg. as_ref ( ) . map ( AsRef :: as_ref) ) {
53+ let manifest_path_arg = std:: env:: args ( ) . skip ( skip) . find ( |val| {
54+ val. starts_with ( "--manifest-path=" )
55+ } ) ;
56+
57+ let mut metadata = if let Ok ( metadata) = cargo_metadata:: metadata (
58+ manifest_path_arg. as_ref ( ) . map ( AsRef :: as_ref) ,
59+ )
60+ {
5661 metadata
5762 } else {
58- let _ = std:: io:: stderr ( ) . write_fmt ( format_args ! ( "error: Could not obtain cargo metadata." ) ) ;
63+ let _ = std:: io:: stderr ( ) . write_fmt ( format_args ! (
64+ "error: Could not obtain cargo metadata."
65+ ) ) ;
5966 std:: process:: exit ( 101 ) ;
6067 } ;
6168
62- let manifest_path = manifest_path_arg. map ( |arg| PathBuf :: from ( Path :: new ( & arg[ "--manifest-path=" . len ( ) ..] ) ) ) ;
69+ let manifest_path = manifest_path_arg. map ( |arg| {
70+ PathBuf :: from ( Path :: new ( & arg[ "--manifest-path=" . len ( ) ..] ) )
71+ } ) ;
6372
6473 let current_dir = std:: env:: current_dir ( ) ;
6574
66- let package_index = metadata. packages
75+ let package_index = metadata
76+ . packages
6777 . iter ( )
6878 . position ( |package| {
6979 let package_manifest_path = Path :: new ( & package. manifest_path ) ;
7080 if let Some ( ref manifest_path) = manifest_path {
7181 package_manifest_path == manifest_path
7282 } else {
73- let current_dir = current_dir. as_ref ( ) . expect ( "could not read current directory" ) ;
74- let package_manifest_directory = package_manifest_path. parent ( )
75- . expect ( "could not find parent directory of package manifest" ) ;
83+ let current_dir = current_dir. as_ref ( ) . expect (
84+ "could not read current directory" ,
85+ ) ;
86+ let package_manifest_directory = package_manifest_path. parent ( ) . expect (
87+ "could not find parent directory of package manifest" ,
88+ ) ;
7689 package_manifest_directory == current_dir
7790 }
7891 } )
7992 . expect ( "could not find matching package" ) ;
8093 let package = metadata. packages . remove ( package_index) ;
8194 for target in package. targets {
8295 let args = std:: env:: args ( ) . skip ( skip) ;
83- let kind = target. kind . get ( 0 ) . expect ( "badly formatted cargo metadata: target::kind is an empty array" ) ;
96+ let kind = target. kind . get ( 0 ) . expect (
97+ "badly formatted cargo metadata: target::kind is an empty array" ,
98+ ) ;
8499 if test && kind == "test" {
85- if let Err ( code) = process ( vec ! [ "--test" . to_string( ) , target. name] . into_iter ( ) . chain ( args) ) {
100+ if let Err ( code) = process (
101+ vec ! [ "--test" . to_string( ) , target. name] . into_iter ( ) . chain (
102+ args,
103+ ) ,
104+ )
105+ {
86106 std:: process:: exit ( code) ;
87107 }
88108 } else if !test && kind == "bin" {
89- if let Err ( code) = process ( vec ! [ "--bin" . to_string( ) , target. name] . into_iter ( ) . chain ( args) ) {
109+ if let Err ( code) = process (
110+ vec ! [ "--bin" . to_string( ) , target. name] . into_iter ( ) . chain (
111+ args,
112+ ) ,
113+ )
114+ {
90115 std:: process:: exit ( code) ;
91116 }
92117 }
@@ -118,7 +143,11 @@ fn main() {
118143 let mut args: Vec < String > = if std:: env:: args ( ) . any ( |s| s == "--sysroot" ) {
119144 std:: env:: args ( ) . skip ( 1 ) . collect ( )
120145 } else {
121- std:: env:: args ( ) . skip ( 1 ) . chain ( Some ( "--sysroot" . to_owned ( ) ) ) . chain ( Some ( sys_root) ) . collect ( )
146+ std:: env:: args ( )
147+ . skip ( 1 )
148+ . chain ( Some ( "--sysroot" . to_owned ( ) ) )
149+ . chain ( Some ( sys_root) )
150+ . collect ( )
122151 } ;
123152
124153 // this check ensures that dependencies are built but not interpreted and the final crate is
@@ -137,17 +166,20 @@ fn main() {
137166 args. extend_from_slice ( & [ "--cfg" . to_owned ( ) , r#"feature="cargo-miri""# . to_owned ( ) ] ) ;
138167
139168 match command. args ( & args) . status ( ) {
140- Ok ( exit) => if !exit. success ( ) {
141- std:: process:: exit ( exit. code ( ) . unwrap_or ( 42 ) ) ;
142- } ,
169+ Ok ( exit) => {
170+ if !exit. success ( ) {
171+ std:: process:: exit ( exit. code ( ) . unwrap_or ( 42 ) ) ;
172+ }
173+ }
143174 Err ( ref e) if miri_enabled => panic ! ( "error during miri run: {:?}" , e) ,
144175 Err ( ref e) => panic ! ( "error during rustc call: {:?}" , e) ,
145176 }
146177 }
147178}
148179
149180fn process < I > ( old_args : I ) -> Result < ( ) , i32 >
150- where I : Iterator < Item = String >
181+ where
182+ I : Iterator < Item = String > ,
151183{
152184 let mut args = vec ! [ "rustc" . to_owned( ) ] ;
153185
0 commit comments