Skip to content

Commit 04e32fb

Browse files
committed
Remove code duplicates
1 parent 14dde99 commit 04e32fb

File tree

1 file changed

+6
-12
lines changed
  • crates/ra_project_model/src

1 file changed

+6
-12
lines changed

crates/ra_project_model/src/lib.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -558,18 +558,12 @@ pub fn get_rustc_cfg_options(target: Option<&String>) -> CfgOptions {
558558

559559
match (|| -> Result<String> {
560560
// `cfg(test)` and `cfg(debug_assertion)` are handled outside, so we suppress them here.
561-
let output = if let Some(target) = target {
562-
Command::new("rustc")
563-
.args(&["--print", "cfg", "-O", "--target", target.as_str()])
564-
.output()
565-
.context("Failed to get output from rustc --print cfg -O")?
566-
} else {
567-
Command::new("rustc")
568-
.args(&["--print", "cfg", "-O"])
569-
.output()
570-
.context("Failed to get output from rustc --print cfg -O")?
571-
};
572-
561+
let mut cmd = Command::new("rustc");
562+
cmd.args(&["--print", "cfg", "-O"]);
563+
if let Some(target) = target {
564+
cmd.args(&["--target", target.as_str()]);
565+
}
566+
let output = cmd.output().context("Failed to get output from rustc --print cfg -O")?;
573567
if !output.status.success() {
574568
bail!(
575569
"rustc --print cfg -O exited with exit code ({})",

0 commit comments

Comments
 (0)