summaryrefslogtreecommitdiff
path: root/scripts/rustdoc_test_builder.rs
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-10-09 21:05:25 +0200
committerMark Brown <broonie@kernel.org>2026-10-09 21:05:25 +0200
commitbfe67cc3798287bfca334d92f342e093f233f2c2 (patch)
tree9cbf2394ec9f808731babf5a73cf965a421660c0 /scripts/rustdoc_test_builder.rs
parenteb413c99c921f34ccb49044c884d540c025990d8 (diff)
parent2dee3d3adcadcc57d62ba6608cd02f50b0c10264 (diff)
downloadlinux-next-bfe67cc3798287bfca334d92f342e093f233f2c2.tar.gz
linux-next-bfe67cc3798287bfca334d92f342e093f233f2c2.zip
Merge branch 'rust-next' of https://github.com/Rust-for-Linux/linux.git
Diffstat (limited to 'scripts/rustdoc_test_builder.rs')
-rw-r--r--scripts/rustdoc_test_builder.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/scripts/rustdoc_test_builder.rs b/scripts/rustdoc_test_builder.rs
index df864437cef7..0361e22853f2 100644
--- a/scripts/rustdoc_test_builder.rs
+++ b/scripts/rustdoc_test_builder.rs
@@ -72,6 +72,13 @@ fn main() {
// Figure out a smaller test name based on the generated function name.
let name = rustdoc_function_name.split_once("_rust_kernel_").unwrap().1;
+ // The `rustdoc` function name can include the absolute path when building with `O=` which is
+ // undesirable and creates overlong symbol names. Remap it to use a relative path.
+ // TODO: Remove when bumping the minimum version since with Rust >= 1.95 we already do the
+ // path remapping via the `rustdoc` `--remap-path-prefix` flag.
+ let trimmed_function_name = format!("_doctest_main_rust_kernel_{name}");
+ let body = body.replace(&rustdoc_function_name, &trimmed_function_name);
+
let path = format!("rust/test/doctests/kernel/{name}");
std::fs::write(path, body.as_bytes()).unwrap();