pull function out into new crate ra_env; use in ra_flycheck as well

This commit is contained in:
Craig Disselkoen 2020-05-05 14:07:10 -07:00
parent 5aa1bba107
commit 303b444dbb
9 changed files with 31 additions and 16 deletions

View file

@ -1,7 +1,6 @@
//! FIXME: write short doc here
mod cargo_workspace;
mod find_executables;
mod json_project;
mod sysroot;
@ -15,6 +14,7 @@ use std::{
use anyhow::{bail, Context, Result};
use ra_cfg::CfgOptions;
use ra_db::{CrateGraph, CrateName, Edition, Env, ExternSource, ExternSourceId, FileId};
use ra_env::get_path_for_executable;
use rustc_hash::FxHashMap;
use serde_json::from_reader;
@ -559,7 +559,7 @@ pub fn get_rustc_cfg_options(target: Option<&String>) -> CfgOptions {
match (|| -> Result<String> {
// `cfg(test)` and `cfg(debug_assertion)` are handled outside, so we suppress them here.
let mut cmd = Command::new("rustc");
let mut cmd = Command::new(get_path_for_executable("rustc")?);
cmd.args(&["--print", "cfg", "-O"]);
if let Some(target) = target {
cmd.args(&["--target", target.as_str()]);