Skip to content

Commit 946c5ef

Browse files
nbdd0121ojeda
authored andcommitted
rust: fix off-by-one line number in rustdoc tests
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: ab844cf ("rust: allow `unreachable_pub` for doctests") Signed-off-by: Gary Guo <gary@garyguo.net> Reviewed-by: David Gow <davidgow@google.com> Link: https://patch.msgid.link/20251211182208.2791025-1-gary@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent f6b8d4b commit 946c5ef

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

scripts/rustdoc_test_gen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ pub extern "C" fn {kunit_name}(__kunit_test: *mut ::kernel::bindings::kunit) {{
206206
207207
/// The anchor where the test code body starts.
208208
#[allow(unused)]
209-
static __DOCTEST_ANCHOR: i32 = ::core::line!() as i32 + {body_offset} + 1;
209+
static __DOCTEST_ANCHOR: i32 = ::core::line!() as i32 + {body_offset} + 2;
210210
{{
211211
#![allow(unreachable_pub, clippy::disallowed_names)]
212212
{body}

0 commit comments

Comments
 (0)