mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Simplify
This commit is contained in:
parent
bd4d375a64
commit
e88b5fe916
1 changed files with 50 additions and 54 deletions
|
@ -304,14 +304,14 @@ fn cargo_to_crate_graph(
|
|||
for pkg in cargo.packages() {
|
||||
let mut lib_tgt = None;
|
||||
for &tgt in cargo[pkg].targets.iter() {
|
||||
if let Some(crate_id) = add_target_crate_root(
|
||||
if let Some(file_id) = load(&cargo[tgt].root) {
|
||||
let crate_id = add_target_crate_root(
|
||||
&mut crate_graph,
|
||||
&cargo[pkg],
|
||||
&cargo[tgt],
|
||||
&cfg_options,
|
||||
proc_macro_client,
|
||||
load,
|
||||
) {
|
||||
file_id,
|
||||
);
|
||||
if cargo[tgt].kind == TargetKind::Lib {
|
||||
lib_tgt = Some((crate_id, cargo[tgt].name.clone()));
|
||||
pkg_to_lib_crate.insert(pkg, crate_id);
|
||||
|
@ -380,14 +380,14 @@ fn cargo_to_crate_graph(
|
|||
continue;
|
||||
}
|
||||
|
||||
if let Some(crate_id) = add_target_crate_root(
|
||||
if let Some(file_id) = load(&rustc_workspace[tgt].root) {
|
||||
let crate_id = add_target_crate_root(
|
||||
&mut crate_graph,
|
||||
&rustc_workspace[pkg],
|
||||
&rustc_workspace[tgt],
|
||||
&cfg_options,
|
||||
proc_macro_client,
|
||||
load,
|
||||
) {
|
||||
file_id,
|
||||
);
|
||||
pkg_to_lib_crate.insert(pkg, crate_id);
|
||||
// Add dependencies on the core / std / alloc for rustc
|
||||
for (name, krate) in public_deps.iter() {
|
||||
|
@ -432,13 +432,10 @@ fn cargo_to_crate_graph(
|
|||
fn add_target_crate_root(
|
||||
crate_graph: &mut CrateGraph,
|
||||
pkg: &cargo_workspace::PackageData,
|
||||
tgt: &cargo_workspace::TargetData,
|
||||
cfg_options: &CfgOptions,
|
||||
proc_macro_client: &ProcMacroClient,
|
||||
load: &mut dyn FnMut(&AbsPath) -> Option<FileId>,
|
||||
) -> Option<CrateId> {
|
||||
let root = tgt.root.as_path();
|
||||
if let Some(file_id) = load(root) {
|
||||
file_id: FileId,
|
||||
) -> CrateId {
|
||||
let edition = pkg.edition;
|
||||
let cfg_options = {
|
||||
let mut opts = cfg_options.clone();
|
||||
|
@ -471,10 +468,9 @@ fn add_target_crate_root(
|
|||
proc_macro.clone(),
|
||||
);
|
||||
|
||||
return Some(crate_id);
|
||||
}
|
||||
None
|
||||
crate_id
|
||||
}
|
||||
|
||||
fn sysroot_to_crate_graph(
|
||||
crate_graph: &mut CrateGraph,
|
||||
sysroot: &Sysroot,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue