5505: Cleanup CFG API r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-07-23 14:55:22 +00:00 committed by GitHub
commit 8df105b8b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 67 deletions

View file

@ -15,6 +15,7 @@ use paths::{AbsPath, AbsPathBuf};
use ra_cfg::CfgOptions;
use ra_db::{CrateGraph, CrateId, CrateName, Edition, Env, FileId};
use rustc_hash::{FxHashMap, FxHashSet};
use stdx::split_delim;
pub use crate::{
cargo_workspace::{CargoConfig, CargoWorkspace, Package, Target, TargetKind},
@ -529,11 +530,10 @@ fn get_rustc_cfg_options(target: Option<&str>) -> CfgOptions {
match rustc_cfgs {
Ok(rustc_cfgs) => {
for line in rustc_cfgs.lines() {
match line.find('=') {
match split_delim(line, '=') {
None => cfg_options.insert_atom(line.into()),
Some(pos) => {
let key = &line[..pos];
let value = line[pos + 1..].trim_matches('"');
Some((key, value)) => {
let value = value.trim_matches('"');
cfg_options.insert_key_value(key.into(), value.into());
}
}