Skip to content

Commit fc5c255

Browse files
ojedaintel-lab-lkp
authored andcommitted
rust: use the hidden variant of rust-project.json
Very soon after we requested it [1], `rust-analyzer` added support for `.rust-project.json` [2], i.e. the hidden variant of `.rust-project.json`. While this is only a (tiny) issue for kernel developers that use Rust (i.e. so far a very small number compared to the total), the file is not really something most kernel developers need to see, care or modify while working, so it is not really needed to show it by default in listings. It also follows the pattern of other files that are not directly related to the project (unlike e.g. a `Kconfig` file). Thus migrate to it. Cc: Ali Bektas <[email protected]> Cc: Lukas Wirth <[email protected]> Link: rust-lang/rust-analyzer#17816 [1] Link: rust-lang/rust-analyzer#17818 [2] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 7c626ce commit fc5c255

File tree

6 files changed

+10
-8
lines changed

6 files changed

+10
-8
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,4 @@ x509.genkey
176176
sphinx_*/
177177

178178
# Rust analyzer configuration
179-
/rust-project.json
179+
/.rust-project.json

Documentation/rust/quick-start.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ The `rust-analyzer <https://rust-analyzer.github.io/>`_ language server can
259259
be used with many editors to enable syntax highlighting, completion, go to
260260
definition, and other features.
261261

262-
``rust-analyzer`` needs a configuration file, ``rust-project.json``, which
262+
``rust-analyzer`` needs a configuration file, ``.rust-project.json``, which
263263
can be generated by the ``rust-analyzer`` Make target::
264264

265265
make LLVM=1 rust-analyzer

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,7 @@ endif # CONFIG_MODULES
14831483
CLEAN_FILES += vmlinux.symvers modules-only.symvers \
14841484
modules.builtin modules.builtin.modinfo modules.nsdeps \
14851485
compile_commands.json rust/test \
1486-
rust-project.json .vmlinux.objs .vmlinux.export.c
1486+
.rust-project.json .vmlinux.objs .vmlinux.export.c
14871487

14881488
# Directories & files removed with 'make mrproper'
14891489
MRPROPER_FILES += include/config include/generated \
@@ -1621,7 +1621,7 @@ help:
16211621
@echo ' (requires kernel .config)'
16221622
@echo ' rusttest - Runs the Rust tests'
16231623
@echo ' (requires kernel .config; downloads external repos)'
1624-
@echo ' rust-analyzer - Generate rust-project.json rust-analyzer support file'
1624+
@echo ' rust-analyzer - Generate .rust-project.json rust-analyzer support file'
16251625
@echo ' (requires kernel .config)'
16261626
@echo ' dir/file.[os] - Build specified target only'
16271627
@echo ' dir/file.rsi - Build macro expanded source, similar to C preprocessing.'
@@ -1809,7 +1809,7 @@ help:
18091809
@echo ' modules - default target, build the module(s)'
18101810
@echo ' modules_install - install the module'
18111811
@echo ' clean - remove generated files in module directory only'
1812-
@echo ' rust-analyzer - generate rust-project.json rust-analyzer support file'
1812+
@echo ' rust-analyzer - generate .rust-project.json rust-analyzer support file'
18131813
@echo ''
18141814

18151815
ifndef CONFIG_MODULES
@@ -1958,7 +1958,7 @@ quiet_cmd_tags = GEN $@
19581958
tags TAGS cscope gtags: FORCE
19591959
$(call cmd,tags)
19601960

1961-
# Generate rust-project.json (a file that describes the structure of non-Cargo
1961+
# Generate .rust-project.json (a file that describes the structure of non-Cargo
19621962
# Rust projects) for rust-analyzer (an implementation of the Language Server
19631963
# Protocol).
19641964
PHONY += rust-analyzer

rust/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ rust-analyzer:
351351
--cfgs='core=$(core-cfgs)' --cfgs='alloc=$(alloc-cfgs)' \
352352
$(realpath $(srctree)) $(realpath $(objtree)) \
353353
$(RUST_LIB_SRC) $(KBUILD_EXTMOD) > \
354-
$(if $(KBUILD_EXTMOD),$(extmod_prefix),$(objtree))/rust-project.json
354+
$(if $(KBUILD_EXTMOD),$(extmod_prefix),$(objtree))/.rust-project.json
355355

356356
redirect-intrinsics = \
357357
__addsf3 __eqsf2 __gesf2 __lesf2 __ltsf2 __mulsf3 __nesf2 __unordsf2 \

scripts/generate_rust_analyzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22
# SPDX-License-Identifier: GPL-2.0
3-
"""generate_rust_analyzer - Generates the `rust-project.json` file for `rust-analyzer`.
3+
"""generate_rust_analyzer - Generates the `.rust-project.json` file for `rust-analyzer`.
44
"""
55

66
import argparse

scripts/remove-stale-files

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ set -e
2121
# then will be really dead and removed from the code base entirely.
2222

2323
rm -f *.spec
24+
25+
rm -f rust-project.json

0 commit comments

Comments
 (0)