mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
⬆️ rust-analyzer
This commit is contained in:
parent
a1f1b95d00
commit
9d2cb42a41
45 changed files with 766 additions and 242 deletions
|
@ -66,7 +66,9 @@ pub fn load_workspace(
|
|||
};
|
||||
|
||||
let crate_graph = ws.to_crate_graph(
|
||||
&mut |_, path: &AbsPath| load_proc_macro(proc_macro_client.as_ref(), path, &[]),
|
||||
&mut |_, path: &AbsPath| {
|
||||
load_proc_macro(proc_macro_client.as_ref().map_err(|e| &**e), path, &[])
|
||||
},
|
||||
&mut |path: &AbsPath| {
|
||||
let contents = loader.load_sync(path);
|
||||
let path = vfs::VfsPath::from(path.to_path_buf());
|
||||
|
|
|
@ -303,6 +303,9 @@ impl GlobalState {
|
|||
let files_config = self.config.files();
|
||||
let project_folders = ProjectFolders::new(&self.workspaces, &files_config.exclude);
|
||||
|
||||
let standalone_server_name =
|
||||
format!("rust-analyzer-proc-macro-srv{}", std::env::consts::EXE_SUFFIX);
|
||||
|
||||
if self.proc_macro_clients.is_empty() {
|
||||
if let Some((path, args)) = self.config.proc_macro_srv() {
|
||||
self.proc_macro_clients = self
|
||||
|
@ -316,10 +319,8 @@ impl GlobalState {
|
|||
tracing::info!("Found a cargo workspace...");
|
||||
if let Some(sysroot) = sysroot.as_ref() {
|
||||
tracing::info!("Found a cargo workspace with a sysroot...");
|
||||
let server_path = sysroot
|
||||
.root()
|
||||
.join("libexec")
|
||||
.join("rust-analyzer-proc-macro-srv");
|
||||
let server_path =
|
||||
sysroot.root().join("libexec").join(&standalone_server_name);
|
||||
if std::fs::metadata(&server_path).is_ok() {
|
||||
tracing::info!(
|
||||
"And the server exists at {}",
|
||||
|
@ -389,7 +390,10 @@ impl GlobalState {
|
|||
|
||||
let mut crate_graph = CrateGraph::default();
|
||||
for (idx, ws) in self.workspaces.iter().enumerate() {
|
||||
let proc_macro_client = self.proc_macro_clients[idx].as_ref();
|
||||
let proc_macro_client = match self.proc_macro_clients.get(idx) {
|
||||
Some(res) => res.as_ref().map_err(|e| &**e),
|
||||
None => Err("Proc macros are disabled"),
|
||||
};
|
||||
let mut load_proc_macro = move |crate_name: &str, path: &AbsPath| {
|
||||
load_proc_macro(
|
||||
proc_macro_client,
|
||||
|
@ -573,7 +577,7 @@ impl SourceRootConfig {
|
|||
/// Load the proc-macros for the given lib path, replacing all expanders whose names are in `dummy_replace`
|
||||
/// with an identity dummy expander.
|
||||
pub(crate) fn load_proc_macro(
|
||||
server: Result<&ProcMacroServer, &String>,
|
||||
server: Result<&ProcMacroServer, &str>,
|
||||
path: &AbsPath,
|
||||
dummy_replace: &[Box<str>],
|
||||
) -> ProcMacroLoadResult {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue