Skip to contentSkip to conversation

Makefile: rust-analyzer better error handling, documentation

PATCH Applied John Hubbard 4 participants 6 messages Jun 28, 2024 – Jul 9, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover Makefile: rust-analyzer better error handling, documentation

Changes since v2:

1) Used wording suggested by Miguel Ojeda (thanks!) for the documentation patch.

2) Added review, testing, ack tags.

Finn Behrens, thanks for your reviews, and please note that out of an excess of caution, I've only applied your reviewed-by tag to patch 2/2. For patch 1/2, the wording changed a lot after you reviewed it, so I couldn't quite convince myself that the review was still fair to claim.

Changes since v1:

1) Thanks to Alice Ryhl for testing and reviewing v1. I had to drop both of those tags for this v2, because even though it is small, it's different enough to invalidate both, unfortunately.

2) Adopted Miguel Ojeda's suggestion of letting rust_is_available.sh report its results directly, thus improving the output, while also simplifying the patch.

3) As requested by Miguel, split out some new comment documentation for the rust-analyzer target into its own patch.

John Hubbard (2):
Makefile: rust-analyzer target: better error handling
Makefile: improve comment documentation for the rust-analyzer target

 Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

base-commit: 6d6444ba82053c716fb5ac83346202659023044e

Signature · 1 line
2.45.2
#1 lore raw

PATCH v3 1/2 Makefile: rust-analyzer target: better error handling

1) Provide a better error message for the "Rust not available" case. Without this patch, one gets various misleading messages, such as:

"No rule to make target 'rust-analyzer'"

Instead, run scripts/rust_is_available.sh directly, as a prerequisite, and let that script report the cause of any problems, as well as providing a link to the documentation. Thanks to Miguel Ojeda for the idea of just letting rust_is_available.sh report its results directly.

The new output in the failure case looks like this:

$ make rust-analyzer
***
*** Rust compiler 'rustc' could not be found.
***
***
*** Please see Documentation/rust/quick-start.rst for details
*** on how to set up the Rust support.
***
make[1]: *** [/kernel_work/linux-github/Makefile:1975: rust-analyzer] Error 1
make: *** [Makefile:240: __sub-make] Error 2
---
 Makefile | 1 +
 1 file changed, 1 insertion(+)
Makefile +1 -0
index 4d36f943b3b1..204e9be0e010 100644
@@ -1970,6 +1970,7 @@ tags TAGS cscope gtags: FORCE
 # IDE support targets
 PHONY += rust-analyzer
 rust-analyzer:
+	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/rust_is_available.sh
 	$(Q)$(MAKE) $(build)=rust $@
 
 # Script to generate missing namespace dependencies
Signature · 1 line
2.45.2
#2 lore raw

PATCH v3 2/2 Makefile: improve comment documentation for the rust-analyzer target

In reply to John Hubbard

Replace the cryptic phrase ("IDE support targets") that initially appears to be about how to support old hard drives, with a few sentences that explain what "make rust-analyzer" provides.

---
 Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Makefile +3 -1
index 204e9be0e010..7db597bdb09d 100644
@@ -1967,7 +1967,9 @@ quiet_cmd_tags = GEN     $@
 tags TAGS cscope gtags: FORCE
 	$(call cmd,tags)
 
-# IDE support targets
+# 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
 rust-analyzer:
 	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/rust_is_available.sh
Signature · 1 line
2.45.2
reviewer Reviewed-by on v3 2/2
#3 lore raw

Re: [PATCH v3 2/2] Makefile: improve comment documentation for the rust-analyzer target

Quoted 9 lines · John Hubbard

Replace the cryptic phrase ("IDE support targets") that initially appears to be about how to support old hard drives, with a few sentences that explain what "make rust-analyzer" provides.

Reviewed-by on v3 2/2
#4 lore raw

Re: [PATCH v3 2/2] Makefile: improve comment documentation for the rust-analyzer target

In reply to John Hubbard
Quoted 8 lines · John Hubbard

Replace the cryptic phrase ("IDE support targets") that initially appears to be about how to support old hard drives, with a few sentences that explain what "make rust-analyzer" provides.

Applied
#5 lore raw
In reply to John Hubbard
Quoted 6 lines · John Hubbard

Changes since v2:

1) Used wording suggested by Miguel Ojeda (thanks!) for the documentation patch.

Quoted 6 lines

2) Added review, testing, ack tags.

Finn Behrens, thanks for your reviews, and please note that out of an excess of caution, I've only applied your reviewed-by tag to patch 2/2. For patch 1/2, the wording changed a lot after you reviewed it, so I couldn't quite convince myself that the review was still fair to claim.

Applied to rust-next -- thanks!

[ Reworded title. - Miguel ]

Cheers,
Miguel