@@ -208,29 +208,9 @@ impl WorkspaceHitlist {
208
208
// Returns a vector of all compile targets of a crate
209
209
fn get_targets ( workspace_hitlist : & WorkspaceHitlist ) -> Result < Vec < Target > , std:: io:: Error > {
210
210
let mut targets: Vec < Target > = vec ! [ ] ;
211
- if * workspace_hitlist == WorkspaceHitlist :: None {
212
- let output = Command :: new ( "cargo" ) . arg ( "read-manifest" ) . output ( ) ?;
213
- if output. status . success ( ) {
214
- // None of the unwraps should fail if output of `cargo read-manifest` is correct
215
- let data = & String :: from_utf8 ( output. stdout ) . unwrap ( ) ;
216
- let json: Value = json:: from_str ( data) . unwrap ( ) ;
217
- let json_obj = json. as_object ( ) . unwrap ( ) ;
218
- let jtargets = json_obj. get ( "targets" ) . unwrap ( ) . as_array ( ) . unwrap ( ) ;
219
- for jtarget in jtargets {
220
- targets. push ( target_from_json ( jtarget) ) ;
221
- }
222
211
223
- return Ok ( targets) ;
224
212
}
225
- return Err ( std:: io:: Error :: new (
226
- std:: io:: ErrorKind :: NotFound ,
227
- str:: from_utf8 ( & output. stderr ) . unwrap ( ) ,
228
- ) ) ;
229
213
}
230
- // This happens when cargo-fmt is not used inside a crate or
231
- // is used inside a workspace.
232
- // To ensure backward compatability, we only use `cargo metadata` for workspaces.
233
- // TODO: Is it possible only use metadata or read-manifest
234
214
let output = Command :: new ( "cargo" )
235
215
. arg ( "metadata" )
236
216
. arg ( "--no-deps" )
@@ -275,12 +255,6 @@ fn get_targets(workspace_hitlist: &WorkspaceHitlist) -> Result<Vec<Target>, std:
275
255
targets. push ( target_from_json ( jtarget) ) ;
276
256
}
277
257
}
278
- return Ok ( targets) ;
279
- }
280
- Err ( std:: io:: Error :: new (
281
- std:: io:: ErrorKind :: NotFound ,
282
- str:: from_utf8 ( & output. stderr ) . unwrap ( ) ,
283
- ) )
284
258
}
285
259
286
260
fn target_from_json ( jtarget : & Value ) -> Target {
0 commit comments