From nobody Thu Dec 18 08:17:02 2025 Received: from gimli.kloenk.de (gimli.kloenk.de [49.12.72.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EB17214A66; Thu, 5 Dec 2024 11:54:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=49.12.72.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733399697; cv=none; b=IKFQ6JMskKI9Z/yqvD0bhocYE4JvcAl33pltCifH9GeI4a2BThxrd2dfp75KT0az7JM9kE60QEiqNUXdFk71jwo/wcxLHurPaGtxueciSwlQGeqx7XRE9QLifzhxcBM3i8FkeYEwLDS49JmHvFRc81qmjvZby3L9L9gjLXei/1Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733399697; c=relaxed/simple; bh=KMCyE9ZJAMDAtajI/0HnPjFXXAaDm7gGd9JBbnwHi1k=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=RnXQ72rdzKh9jyfb000igcUqK9njvq4OHLz2Pw5/7Op3fRITJm+97GLmYPhOh5pVXcvko+OKUH5p1WcWCmUABxW0saICPMEvfKdd5XnGlSTwaF0jegMdYZMFUxOaumXO6alT4ODp2P+XrZVBgl6QbmB6fh6rTlwQnT75KeuA+Zg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kloenk.dev; spf=pass smtp.mailfrom=kloenk.dev; dkim=pass (1024-bit key) header.d=kloenk.dev header.i=@kloenk.dev header.b=lvcX9czy; arc=none smtp.client-ip=49.12.72.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kloenk.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kloenk.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kloenk.dev header.i=@kloenk.dev header.b="lvcX9czy" From: Fiona Behrens DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kloenk.dev; s=mail; t=1733399689; bh=mkOrmXx5DpCU18D4nh+JipCWuV+F7TBWM+/XgGowy6I=; h=From:To:Cc:Subject:Date; b=lvcX9czyaxx/WYvwH1DTFyhdGOHLKHGFtJ/WbfkI9O/OlERgMc3LDbRbAYTbOBXyM kN3BI4oP46+QySdAFDvgkQzXoQyAyEjGqNbt9cT7WVuMrPV3PYpsNwoOFXuiNh6FIk ocxBQmnroMnnobrsmrRBtlBQEOHVSh9Q06wAazqY= To: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross Cc: Fiona Behrens , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rust: rust-analyzer: add proc_macro for macros crate Date: Thu, 5 Dec 2024 12:54:36 +0100 Message-ID: <20241205115438.234221-1-me@kloenk.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Fiona Behrens Reviewed-by: Alice Ryhl --- scripts/generate_rust_analyzer.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_anal= yzer.py index 09e1d166d8d2..747b5ed6c857 100755 --- a/scripts/generate_rust_analyzer.py +++ b/scripts/generate_rust_analyzer.py @@ -64,10 +64,34 @@ def generate_crates(srctree, objtree, sysroot_src, exte= rnal_src, cfgs): [], ) =20 + # alloc only for std/proc_macros/macros + append_crate( + "alloc", + sysroot_src / "alloc" / "src" / "lib.rs", + ["core"], + is_workspace_member=3DFalse, + ) + + # std only for proc_macros/macros + append_crate( + "std", + sysroot_src / "std" / "src" / "lib.rs", + ["core", "alloc"], + is_workspace_member=3DFalse, + ) + + # proc_macro for macros crate + append_crate( + "proc_macro", + sysroot_src / "proc_macro" / "src" / "lib.rs", + ["std", "core"], + is_workspace_member=3DFalse, + ) + append_crate( "macros", srctree / "rust" / "macros" / "lib.rs", - [], + ["std", "proc_macro"], is_proc_macro=3DTrue, ) crates[-1]["proc_macro_dylib_path"] =3D f"{objtree}/rust/libmacros.so" --=20 2.47.0