Rust project supports proc-macro dependent crates
This commit is contained in:
parent
df0936b4af
commit
cb13e4a2ca
@ -37,6 +37,7 @@ pub struct Crate {
|
|||||||
pub(crate) is_workspace_member: bool,
|
pub(crate) is_workspace_member: bool,
|
||||||
pub(crate) include: Vec<AbsPathBuf>,
|
pub(crate) include: Vec<AbsPathBuf>,
|
||||||
pub(crate) exclude: Vec<AbsPathBuf>,
|
pub(crate) exclude: Vec<AbsPathBuf>,
|
||||||
|
pub(crate) is_proc_macro: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProjectJson {
|
impl ProjectJson {
|
||||||
@ -96,6 +97,7 @@ impl ProjectJson {
|
|||||||
is_workspace_member,
|
is_workspace_member,
|
||||||
include,
|
include,
|
||||||
exclude,
|
exclude,
|
||||||
|
is_proc_macro: crate_data.is_proc_macro,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
@ -135,6 +137,8 @@ struct CrateData {
|
|||||||
proc_macro_dylib_path: Option<PathBuf>,
|
proc_macro_dylib_path: Option<PathBuf>,
|
||||||
is_workspace_member: Option<bool>,
|
is_workspace_member: Option<bool>,
|
||||||
source: Option<CrateSource>,
|
source: Option<CrateSource>,
|
||||||
|
#[serde(default)]
|
||||||
|
is_proc_macro: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
|
@ -446,10 +446,20 @@ fn project_json_to_crate_graph(
|
|||||||
|
|
||||||
for (from, krate) in project.crates() {
|
for (from, krate) in project.crates() {
|
||||||
if let Some(&from) = crates.get(&from) {
|
if let Some(&from) = crates.get(&from) {
|
||||||
if let Some((public_deps, _proc_macro)) = &sysroot_deps {
|
if let Some((public_deps, libproc_macro)) = &sysroot_deps {
|
||||||
for (name, to) in public_deps.iter() {
|
for (name, to) in public_deps.iter() {
|
||||||
add_dep(&mut crate_graph, from, name.clone(), *to)
|
add_dep(&mut crate_graph, from, name.clone(), *to)
|
||||||
}
|
}
|
||||||
|
if krate.is_proc_macro {
|
||||||
|
if let Some(proc_macro) = libproc_macro {
|
||||||
|
add_dep(
|
||||||
|
&mut crate_graph,
|
||||||
|
from,
|
||||||
|
CrateName::new("proc_macro").unwrap(),
|
||||||
|
*proc_macro,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for dep in &krate.deps {
|
for dep in &krate.deps {
|
||||||
|
@ -578,6 +578,8 @@ interface Crate {
|
|||||||
/// the `env!` macro
|
/// the `env!` macro
|
||||||
env: : { [key: string]: string; },
|
env: : { [key: string]: string; },
|
||||||
|
|
||||||
|
/// Whether the crate is a proc-macro crate.
|
||||||
|
is_proc_macro: bool;
|
||||||
/// For proc-macro crates, path to compiled
|
/// For proc-macro crates, path to compiled
|
||||||
/// proc-macro (.so file).
|
/// proc-macro (.so file).
|
||||||
proc_macro_dylib_path?: string;
|
proc_macro_dylib_path?: string;
|
||||||
@ -597,7 +599,7 @@ Specifically, the `roots` setup will be different eventually.
|
|||||||
|
|
||||||
There are three ways to feed `rust-project.json` to rust-analyzer:
|
There are three ways to feed `rust-project.json` to rust-analyzer:
|
||||||
|
|
||||||
* Place `rust-project.json` file at the root of the project, and rust-anlayzer will discover it.
|
* Place `rust-project.json` file at the root of the project, and rust-analyzer will discover it.
|
||||||
* Specify `"rust-analyzer.linkedProjects": [ "path/to/rust-project.json" ]` in the settings (and make sure that your LSP client sends settings as a part of initialize request).
|
* Specify `"rust-analyzer.linkedProjects": [ "path/to/rust-project.json" ]` in the settings (and make sure that your LSP client sends settings as a part of initialize request).
|
||||||
* Specify `"rust-analyzer.linkedProjects": [ { "roots": [...], "crates": [...] }]` inline.
|
* Specify `"rust-analyzer.linkedProjects": [ { "roots": [...], "crates": [...] }]` inline.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user