Skip to contentSkip to conversation

rust: doctest: add source map script

RFC PATCH New Gary Guo 1 participant 1 message Jun 12

Subsystems (3)
lore
Share & tools
lore

Gary Guo

author
#0 lore raw

RFC PATCH 1/1 rust: doctest: add source map script

From: Gary Guo <[email protected]>

Quite often when updating abstractions there will be some documentation that needs updating, but the build process is not very developer friendly as it just gives out something like "rust/doctests_kernel_generated.rs:12345:42" and it is a hassle to find where the documentation actually is.

Add a script as rustc wrapper, which translates the error message by appending a "(generated from original_file:original_line:col)" message to the original source info emitted by rustc.

---
I made this a rustc wrapper instead of trying to pipe rustc output to it, as Kbuild is too complex for me to understand how to do it :)

---
 rust/Makefile                           |  4 ++
 scripts/rustdoc_test_build_sourcemap.py | 71 +++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 100644 scripts/rustdoc_test_build_sourcemap.py
rust/Makefile +4 -0
index 63b1e355321d..d133d4fe1f2d 100644
@@ -393,6 +393,10 @@ quiet_cmd_rustdoc_test_kernel = RUSTDOC TK $<
     $(objtree)/scripts/rustdoc_test_gen FORCE
 	+$(call if_changed,rustdoc_test_kernel)
 
+ACTUAL_RUSTC := $(RUSTC_OR_CLIPPY)
+%/doctests_kernel_generated.o: private RUSTC_OR_CLIPPY = \
+	PYTHONDONTWRITEBYTECODE=1 ACTUAL_RUSTC=$(ACTUAL_RUSTC) $(PYTHON3) $(srctree)/scripts/rustdoc_test_build_sourcemap.py
+
 # We cannot use `-Zpanic-abort-tests` because some tests are dynamic,
 # so for the moment we skip `-Cpanic=abort`.
 quiet_cmd_rustc_test = $(RUSTC_OR_CLIPPY_QUIET) T  $<
scripts/rustdoc_test_build_sourcemap.py new file +71 -0

71 lines not on this page · raw message

base-commit: 3782319656f65f0bf020d4c058058c23c3e16679

Signature · 1 line
2.54.0