Re: [PATCH] rust: doctests: Use tabs for indentation in generated C code
From: Miguel Ojeda
Date: Thu Jul 20 2023 - 05:56:00 EST
On Thu, Jul 20, 2023 at 8:30 AM David Gow <davidgow@xxxxxxxxxx> wrote:
>
> While Rust uses 4 spaces for indentation, we should use tabs in the
> generated C code. This does result in some scary-looking tab characters
> in a .rs file, but they're in a string literal, so shouldn't make
> anything complain too much.
>
> Fixes: a66d733da801 ("rust: support running Rust documentation tests as KUnit ones")
> Signed-off-by: David Gow <davidgow@xxxxxxxxxx>
The indentation for the `KUNIT_CASE()` lines should be changed too:
diff --git a/scripts/rustdoc_test_gen.rs b/scripts/rustdoc_test_gen.rs
index 5ebd42ae4a3f..9623e2e6313d 100644
--- a/scripts/rustdoc_test_gen.rs
+++ b/scripts/rustdoc_test_gen.rs
@@ -213,7 +213,7 @@ macro_rules! assert_eq {{
.unwrap();
write!(c_test_declarations, "void {kunit_name}(struct kunit
*);\n").unwrap();
- write!(c_test_cases, " KUNIT_CASE({kunit_name}),\n").unwrap();
+ write!(c_test_cases, " KUNIT_CASE({kunit_name}),\n").unwrap();
}
let rust_tests = rust_tests.trim();
With that:
Acked-by: Miguel Ojeda <ojeda@xxxxxxxxxx>
Since the changes are within string literals, I don't expect issues,
but I just in case I ran it through `checkpatch.pl`, `rustfmt` and
`CLIPPY=1`:
Tested-by: Miguel Ojeda <ojeda@xxxxxxxxxx>
Thanks!
Cheers,
Miguel