Skip to content

Commit 8d86b0e

Browse files
committed
Do not use 'cargo manifest' anymore as it is deprecated
1 parent 0a59654 commit 8d86b0e

File tree

1 file changed

+0
-26
lines changed

1 file changed

+0
-26
lines changed

src/bin/cargo-fmt.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -208,29 +208,9 @@ impl WorkspaceHitlist {
208208
// Returns a vector of all compile targets of a crate
209209
fn get_targets(workspace_hitlist: &WorkspaceHitlist) -> Result<Vec<Target>, std::io::Error> {
210210
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-
}
222211

223-
return Ok(targets);
224212
}
225-
return Err(std::io::Error::new(
226-
std::io::ErrorKind::NotFound,
227-
str::from_utf8(&output.stderr).unwrap(),
228-
));
229213
}
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
234214
let output = Command::new("cargo")
235215
.arg("metadata")
236216
.arg("--no-deps")
@@ -275,12 +255,6 @@ fn get_targets(workspace_hitlist: &WorkspaceHitlist) -> Result<Vec<Target>, std:
275255
targets.push(target_from_json(jtarget));
276256
}
277257
}
278-
return Ok(targets);
279-
}
280-
Err(std::io::Error::new(
281-
std::io::ErrorKind::NotFound,
282-
str::from_utf8(&output.stderr).unwrap(),
283-
))
284258
}
285259

286260
fn target_from_json(jtarget: &Value) -> Target {

0 commit comments

Comments
 (0)