rust: rust-analyzer: add proc_macro for macros crate
Subsystems (2)
PATCH 1/1 rust: rust-analyzer: add proc_macro for macros crate
Add the proc_macro crate from the rust sysroot to the rust-project.json file used by rust-analyzer. This allows rust-analyzer to autocomplete items from the proc_macro crate inside the macros crate.
This also adds std and alloc only to be used by proc_macro and macros. This does not add the dependencies of those crates as this is sufficent for rust-analyzer to have a basic autocompletion support without having to worry about all the dependencies std usually needs. alloc is added, as e.g. std::vec just reexports from alloc, so that macros can use autocompletion for Vec and similar.
--- scripts/generate_rust_analyzer.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
scripts/generate_rust_analyzer.py +25 -1
@@ -64,10 +64,34 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs): [], ) + # alloc only for std/proc_macros/macros + append_crate( + "alloc", + sysroot_src / "alloc" / "src" / "lib.rs", + ["core"], + is_workspace_member=False, + ) + + # std only for proc_macros/macros + append_crate( + "std", + sysroot_src / "std" / "src" / "lib.rs", + ["core", "alloc"], + is_workspace_member=False, + ) + + # proc_macro for macros crate + append_crate( + "proc_macro", + sysroot_src / "proc_macro" / "src" / "lib.rs", + ["std", "core"], + is_workspace_member=False, + ) + append_crate( "macros", srctree / "rust" / "macros" / "lib.rs", - [], + ["std", "proc_macro"], is_proc_macro=True, ) crates[-1]["proc_macro_dylib_path"] = f"{objtree}/rust/libmacros.so"
Signature · 1 line
2.47.0
Quoted 6 lines · Fiona Behrens
Add the
proc_macrocrate from the rust sysroot to the rust-project.json file used by rust-analyzer. This allows rust-analyzer to autocomplete items from theproc_macrocrate inside the macros crate.
Quoted 6 lines
This also adds std and alloc only to be used by
proc_macroand macros. This does not add the dependencies of those crates as this is sufficent for rust-analyzer to have a basic autocompletion support without having to worry about all the dependencies std usually needs. alloc is added, as e.g.std::vecjust reexports from alloc, so that macros can use autocompletion for Vec and similar.
If you say that's sufficient, then I believe you.
Quoted 1 line
Signed-off-by Fiona Behrens <[email protected]>