mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Cleanup CFG API
This commit is contained in:
parent
0cf8ee2dc2
commit
38e38d9b29
6 changed files with 44 additions and 63 deletions
|
@ -16,6 +16,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},
|
||||
|
@ -544,11 +545,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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue