Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH] rust: fix off-by-one line number in rustdoc tests
@ 2025-12-11 18:22 Gary Guo
  2025-12-19 10:38 ` David Gow
  2026-01-04 22:54 ` Miguel Ojeda
  0 siblings, 2 replies; 3+ messages in thread
From: Gary Guo @ 2025-12-11 18:22 UTC (permalink / raw)
  To: Brendan Higgins, David Gow, Rae Moar, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich
  Cc: linux-kselftest, kunit-dev, rust-for-linux, linux-kernel

From: Gary Guo <gary@garyguo.net>

When the `#![allow]` line was added, the doctest line number anchor
isn't updated which causes the line number printed in kunit test to be
off-by-one.

Fixes: ab844cf32058 ("rust: allow `unreachable_pub` for doctests")
Signed-off-by: Gary Guo <gary@garyguo.net>
---
 scripts/rustdoc_test_gen.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/rustdoc_test_gen.rs b/scripts/rustdoc_test_gen.rs
index be05610496605..6fd9f5c84e2e4 100644
--- a/scripts/rustdoc_test_gen.rs
+++ b/scripts/rustdoc_test_gen.rs
@@ -206,7 +206,7 @@ macro_rules! assert_eq {{
 
     /// The anchor where the test code body starts.
     #[allow(unused)]
-    static __DOCTEST_ANCHOR: i32 = ::core::line!() as i32 + {body_offset} + 1;
+    static __DOCTEST_ANCHOR: i32 = ::core::line!() as i32 + {body_offset} + 2;
     {{
         #![allow(unreachable_pub, clippy::disallowed_names)]
         {body}

base-commit: 559e608c46553c107dbba19dae0854af7b219400
-- 
2.51.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] rust: fix off-by-one line number in rustdoc tests
  2025-12-11 18:22 [PATCH] rust: fix off-by-one line number in rustdoc tests Gary Guo
@ 2025-12-19 10:38 ` David Gow
  2026-01-04 22:54 ` Miguel Ojeda
  1 sibling, 0 replies; 3+ messages in thread
From: David Gow @ 2025-12-19 10:38 UTC (permalink / raw)
  To: Gary Guo
  Cc: Brendan Higgins, Rae Moar, Miguel Ojeda, Boqun Feng,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, linux-kselftest, kunit-dev,
	rust-for-linux, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1198 bytes --]

On Fri, 12 Dec 2025 at 02:22, Gary Guo <gary@kernel.org> wrote:
>
> From: Gary Guo <gary@garyguo.net>
>
> When the `#![allow]` line was added, the doctest line number anchor
> isn't updated which causes the line number printed in kunit test to be
> off-by-one.
>
> Fixes: ab844cf32058 ("rust: allow `unreachable_pub` for doctests")
> Signed-off-by: Gary Guo <gary@garyguo.net>
> ---

Nice catch!

Reviewed-by: David Gow <davidgow@google.com>

Cheers,
-- David

>  scripts/rustdoc_test_gen.rs | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/rustdoc_test_gen.rs b/scripts/rustdoc_test_gen.rs
> index be05610496605..6fd9f5c84e2e4 100644
> --- a/scripts/rustdoc_test_gen.rs
> +++ b/scripts/rustdoc_test_gen.rs
> @@ -206,7 +206,7 @@ macro_rules! assert_eq {{
>
>      /// The anchor where the test code body starts.
>      #[allow(unused)]
> -    static __DOCTEST_ANCHOR: i32 = ::core::line!() as i32 + {body_offset} + 1;
> +    static __DOCTEST_ANCHOR: i32 = ::core::line!() as i32 + {body_offset} + 2;
>      {{
>          #![allow(unreachable_pub, clippy::disallowed_names)]
>          {body}
>
> base-commit: 559e608c46553c107dbba19dae0854af7b219400
> --
> 2.51.2
>

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5281 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] rust: fix off-by-one line number in rustdoc tests
  2025-12-11 18:22 [PATCH] rust: fix off-by-one line number in rustdoc tests Gary Guo
  2025-12-19 10:38 ` David Gow
@ 2026-01-04 22:54 ` Miguel Ojeda
  1 sibling, 0 replies; 3+ messages in thread
From: Miguel Ojeda @ 2026-01-04 22:54 UTC (permalink / raw)
  To: Gary Guo
  Cc: Brendan Higgins, David Gow, Rae Moar, Miguel Ojeda, Boqun Feng,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, linux-kselftest, kunit-dev,
	rust-for-linux, linux-kernel

On Thu, Dec 11, 2025 at 7:22 PM Gary Guo <gary@kernel.org> wrote:
>
> From: Gary Guo <gary@garyguo.net>
>
> When the `#![allow]` line was added, the doctest line number anchor
> isn't updated which causes the line number printed in kunit test to be
> off-by-one.
>
> Fixes: ab844cf32058 ("rust: allow `unreachable_pub` for doctests")
> Signed-off-by: Gary Guo <gary@garyguo.net>

Applied to `rust-fixes` -- thanks everyone!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-01-04 22:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-11 18:22 [PATCH] rust: fix off-by-one line number in rustdoc tests Gary Guo
2025-12-19 10:38 ` David Gow
2026-01-04 22:54 ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox