use cfg::{CfgAtom, CfgExpr};
use ide::{FileId, RunnableKind, TestId};
-use project_model::{self, TargetKind};
+use project_model::{self, ManifestPath, TargetKind};
use vfs::AbsPathBuf;
use crate::{global_state::GlobalStateSnapshot, Result};
#[derive(Clone)]
pub(crate) struct CargoTargetSpec {
pub(crate) workspace_root: AbsPathBuf,
- pub(crate) cargo_toml: AbsPathBuf,
+ pub(crate) cargo_toml: ManifestPath,
pub(crate) package: String,
pub(crate) target: String,
pub(crate) target_kind: TargetKind,
}
}
- if snap.config.cargo.all_features {
+ let cargo_config = snap.config.cargo();
+ if cargo_config.all_features {
args.push("--all-features".to_string());
} else {
let mut features = Vec::new();
if let Some(cfg) = cfg.as_ref() {
required_features(cfg, &mut features);
}
- for feature in &snap.config.cargo.features {
+ for feature in cargo_config.features {
features.push(feature.clone());
}
features.dedup();
let res = CargoTargetSpec {
workspace_root: cargo_ws.workspace_root().to_path_buf(),
cargo_toml: package_data.manifest.clone(),
- package: cargo_ws.package_flag(&package_data),
+ package: cargo_ws.package_flag(package_data),
target: target_data.name.clone(),
target_kind: target_data.kind,
};
TargetKind::Lib => {
buf.push("--lib".to_string());
}
- TargetKind::Other => (),
+ TargetKind::Other | TargetKind::BuildScript => (),
}
}
}
use super::*;
use cfg::CfgExpr;
- use mbe::ast_to_token_tree;
+ use mbe::syntax_node_to_token_tree;
use syntax::{
ast::{self, AstNode},
SmolStr,
let cfg_expr = {
let source_file = ast::SourceFile::parse(cfg).ok().unwrap();
let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap();
- let (tt, _) = ast_to_token_tree(&tt).unwrap();
+ let (tt, _) = syntax_node_to_token_tree(tt.syntax());
CfgExpr::parse(&tt)
};