From: "Gary Guo" <gary@garyguo.net>
To: "Gary Guo" <gary@garyguo.net>, "Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Brendan Higgins" <brendan.higgins@linux.dev>,
"David Gow" <david@davidgow.net>,
"Rae Moar" <raemoar63@gmail.com>
Cc: <rust-for-linux@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-kselftest@vger.kernel.org>, <kunit-dev@googlegroups.com>
Subject: Re: [PATCH 2/3] rust: kunit: use `line!()` inside `kunit_assert!`
Date: Mon, 22 Jun 2026 14:00:48 +0100 [thread overview]
Message-ID: <DJFLIG4XLV5P.3SESCCH2A4UPB@garyguo.net> (raw)
In-Reply-To: <20260616-kunit-v1-2-b191604a8d6b@garyguo.net>
On Tue Jun 16, 2026 at 4:24 PM BST, Gary Guo wrote:
> The `diff` parameter is needed currently because doctests want to override
> the line number. Simplify it by changing it to use `line!()`. Have doctests
> override `line!()` macro to achieve the current behavior.
>
> A few current doctests (or their invoked macros) require `line!()` to
> expand to literal; they're updated to use `::core::line!()` instead.
I've found a way to make `concat!()` still work by having a proc macro thats
does the compute at expansion time (which would eliminate the device_id/str.rs
changes). However, doing so would require the full `proc_macro_span` feature, as
it needs to use `.source()` to replicate the
behaviour of `line!()` (which returns the line number of the out-most
macro invocation, not just the caller one-level up).
Alternatively, this can be implemented by using `expand_expr` to invoke
`::core::line!()` itself, however that is also unstable.
Best,
Gary
>
> Signed-off-by: Gary Guo <gary@garyguo.net>
> ---
> rust/kernel/device_id.rs | 2 +-
> rust/kernel/kunit.rs | 8 ++++----
> rust/kernel/str.rs | 2 +-
> rust/macros/kunit.rs | 4 ++--
> scripts/rustdoc_test_gen.rs | 16 ++++++++++++----
> 5 files changed, 20 insertions(+), 12 deletions(-)
next prev parent reply other threads:[~2026-06-22 13:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 15:24 [PATCH 0/3] rust: doctest: unify with other kunit tests Gary Guo
2026-06-16 15:24 ` [PATCH 1/3] rust: kunit: use `file!()` inside `kunit_assert!` Gary Guo
2026-06-20 11:07 ` David Gow
2026-06-16 15:24 ` [PATCH 2/3] rust: kunit: use `line!()` " Gary Guo
2026-06-20 11:07 ` David Gow
2026-06-22 13:00 ` Gary Guo [this message]
2026-06-16 15:24 ` [PATCH 3/3] rust: doctest: generate Rust kunit test suites Gary Guo
2026-06-20 11:07 ` David Gow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DJFLIG4XLV5P.3SESCCH2A4UPB@garyguo.net \
--to=gary@garyguo.net \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=brendan.higgins@linux.dev \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=david@davidgow.net \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=raemoar63@gmail.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®