aboutsummaryrefslogtreecommitdiff
path: root/crates/rust-analyzer/src/cli/load_cargo.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/rust-analyzer/src/cli/load_cargo.rs')
-rw-r--r--crates/rust-analyzer/src/cli/load_cargo.rs20
1 files changed, 4 insertions, 16 deletions
diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs
index 46181b677..8f2aeac77 100644
--- a/crates/rust-analyzer/src/cli/load_cargo.rs
+++ b/crates/rust-analyzer/src/cli/load_cargo.rs
@@ -8,8 +8,7 @@ use crossbeam_channel::{unbounded, Receiver};
8use ra_db::{ExternSourceId, FileId, SourceRootId}; 8use ra_db::{ExternSourceId, FileId, SourceRootId};
9use ra_ide::{AnalysisChange, AnalysisHost}; 9use ra_ide::{AnalysisChange, AnalysisHost};
10use ra_project_model::{ 10use ra_project_model::{
11 get_rustc_cfg_options, CargoConfig, PackageRoot, ProcMacroClient, ProjectManifest, 11 CargoConfig, PackageRoot, ProcMacroClient, ProjectManifest, ProjectWorkspace,
12 ProjectWorkspace,
13}; 12};
14use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask, Watch}; 13use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask, Watch};
15use rustc_hash::{FxHashMap, FxHashSet}; 14use rustc_hash::{FxHashMap, FxHashSet};
@@ -148,25 +147,14 @@ pub(crate) fn load(
148 } 147 }
149 } 148 }
150 149
151 // FIXME: cfg options? 150 let crate_graph =
152 let default_cfg_options = { 151 ws.to_crate_graph(None, &extern_source_roots, proc_macro_client, &mut |path: &Path| {
153 let mut opts = get_rustc_cfg_options(None);
154 opts.insert_atom("debug_assertion".into());
155 opts
156 };
157
158 let crate_graph = ws.to_crate_graph(
159 &default_cfg_options,
160 &extern_source_roots,
161 proc_macro_client,
162 &mut |path: &Path| {
163 // Some path from metadata will be non canonicalized, e.g. /foo/../bar/lib.rs 152 // Some path from metadata will be non canonicalized, e.g. /foo/../bar/lib.rs
164 let path = path.canonicalize().ok()?; 153 let path = path.canonicalize().ok()?;
165 let vfs_file = vfs.load(&path); 154 let vfs_file = vfs.load(&path);
166 log::debug!("vfs file {:?} -> {:?}", path, vfs_file); 155 log::debug!("vfs file {:?} -> {:?}", path, vfs_file);
167 vfs_file.map(vfs_file_to_id) 156 vfs_file.map(vfs_file_to_id)
168 }, 157 });
169 );
170 log::debug!("crate graph: {:?}", crate_graph); 158 log::debug!("crate graph: {:?}", crate_graph);
171 analysis_change.set_crate_graph(crate_graph); 159 analysis_change.set_crate_graph(crate_graph);
172 160