Skip to content

Commit

Permalink
rust: use the hidden variant of rust-project.json
Browse files Browse the repository at this point in the history
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 <bektasali@protonmail.com>
Cc: Lukas Wirth <lukastw97@gmail.com>
Link: rust-lang/rust-analyzer#17816 [1]
Link: rust-lang/rust-analyzer#17818 [2]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
  • Loading branch information
ojeda authored and intel-lab-lkp committed Aug 17, 2024
1 parent 7c626ce commit fc5c255
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,4 @@ x509.genkey
sphinx_*/

# Rust analyzer configuration
/rust-project.json
/.rust-project.json
2 changes: 1 addition & 1 deletion Documentation/rust/quick-start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ The `rust-analyzer <https://rust-analyzer.github.io/>`_ language server can
be used with many editors to enable syntax highlighting, completion, go to
definition, and other features.

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

make LLVM=1 rust-analyzer
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,7 @@ endif # CONFIG_MODULES
CLEAN_FILES += vmlinux.symvers modules-only.symvers \
modules.builtin modules.builtin.modinfo modules.nsdeps \
compile_commands.json rust/test \
rust-project.json .vmlinux.objs .vmlinux.export.c
.rust-project.json .vmlinux.objs .vmlinux.export.c

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

ifndef CONFIG_MODULES
Expand Down Expand Up @@ -1958,7 +1958,7 @@ quiet_cmd_tags = GEN $@
tags TAGS cscope gtags: FORCE
$(call cmd,tags)

# Generate rust-project.json (a file that describes the structure of non-Cargo
# Generate .rust-project.json (a file that describes the structure of non-Cargo
# Rust projects) for rust-analyzer (an implementation of the Language Server
# Protocol).
PHONY += rust-analyzer
Expand Down
2 changes: 1 addition & 1 deletion rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ rust-analyzer:
--cfgs='core=$(core-cfgs)' --cfgs='alloc=$(alloc-cfgs)' \
$(realpath $(srctree)) $(realpath $(objtree)) \
$(RUST_LIB_SRC) $(KBUILD_EXTMOD) > \
$(if $(KBUILD_EXTMOD),$(extmod_prefix),$(objtree))/rust-project.json
$(if $(KBUILD_EXTMOD),$(extmod_prefix),$(objtree))/.rust-project.json

redirect-intrinsics = \
__addsf3 __eqsf2 __gesf2 __lesf2 __ltsf2 __mulsf3 __nesf2 __unordsf2 \
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_rust_analyzer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
"""generate_rust_analyzer - Generates the `rust-project.json` file for `rust-analyzer`.
"""generate_rust_analyzer - Generates the `.rust-project.json` file for `rust-analyzer`.
"""

import argparse
Expand Down
2 changes: 2 additions & 0 deletions scripts/remove-stale-files
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ set -e
# then will be really dead and removed from the code base entirely.

rm -f *.spec

rm -f rust-project.json

0 comments on commit fc5c255

Please sign in to comment.