Remove code duplicates

This commit is contained in:
Christophe MASSOLIN 2020-05-05 18:23:47 +02:00
parent 14dde99627
commit 04e32fbffc

View file

@ -558,18 +558,12 @@ pub fn get_rustc_cfg_options(target: Option<&String>) -> CfgOptions {
match (|| -> Result<String> { match (|| -> Result<String> {
// `cfg(test)` and `cfg(debug_assertion)` are handled outside, so we suppress them here. // `cfg(test)` and `cfg(debug_assertion)` are handled outside, so we suppress them here.
let output = if let Some(target) = target { let mut cmd = Command::new("rustc");
Command::new("rustc") cmd.args(&["--print", "cfg", "-O"]);
.args(&["--print", "cfg", "-O", "--target", target.as_str()]) if let Some(target) = target {
.output() cmd.args(&["--target", target.as_str()]);
.context("Failed to get output from rustc --print cfg -O")? }
} else { let output = cmd.output().context("Failed to get output from rustc --print cfg -O")?;
Command::new("rustc")
.args(&["--print", "cfg", "-O"])
.output()
.context("Failed to get output from rustc --print cfg -O")?
};
if !output.status.success() { if !output.status.success() {
bail!( bail!(
"rustc --print cfg -O exited with exit code ({})", "rustc --print cfg -O exited with exit code ({})",