From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Jesung Yang" <y.j3ms.n@gmail.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"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>,
"Alexandre Courbot" <acourbot@nvidia.com>
Cc: <linux-kernel@vger.kernel.org>, <rust-for-linux@vger.kernel.org>,
<nouveau@lists.freedesktop.org>
Subject: Re: [PATCH v2 2/5] rust: macros: extend custom `quote!()` macro
Date: Tue, 30 Sep 2025 13:58:22 +0900 [thread overview]
Message-ID: <DD5VAPG2QFWA.2A58AL13VHPN2@nvidia.com> (raw)
In-Reply-To: <948a28f26a0e9924d82eb1d8d377e3ddc7335b24.1755235180.git.y.j3ms.n@gmail.com>
Hi Jesung,
On Fri Aug 15, 2025 at 2:32 PM JST, Jesung Yang wrote:
> Extend the `quote_spanned!()` macro to support additional punctuation
> tokens: `->`, `<`, `>`, and `==`. This symbols are commonly needed when
> dealing with functions, generic bounds, and equality comparisons.
>
> Tested-by: Alexandre Courbot <acourbot@nvidia.com>
> Signed-off-by: Jesung Yang <y.j3ms.n@gmail.com>
> ---
Note that this patch doesn't apply cleanly in `rust-next`, I've had to
add the following on top of it.
I suggest waiting for -rc1 to be released and using it as a base for a
new version - hopefully this will also give time for more feedback to
come.
diff --git a/rust/macros/quote.rs b/rust/macros/quote.rs
index 76a99f7e01c4..bb6970fd2a26 100644
--- a/rust/macros/quote.rs
+++ b/rust/macros/quote.rs
@@ -147,33 +147,33 @@ macro_rules! quote_spanned {
quote_spanned!(@proc $v $span $($tt)*);
};
(@proc $v:ident $span:ident -> $($tt:tt)*) => {
- $v.push(::proc_macro::TokenTree::Punct(
+ $v.extend([::proc_macro::TokenTree::Punct(
::proc_macro::Punct::new('-', ::proc_macro::Spacing::Joint)
- ));
- $v.push(::proc_macro::TokenTree::Punct(
+ )]);
+ $v.extend([::proc_macro::TokenTree::Punct(
::proc_macro::Punct::new('>', ::proc_macro::Spacing::Alone)
- ));
+ )]);
quote_spanned!(@proc $v $span $($tt)*);
};
(@proc $v:ident $span:ident < $($tt:tt)*) => {
- $v.push(::proc_macro::TokenTree::Punct(
+ $v.extend([::proc_macro::TokenTree::Punct(
::proc_macro::Punct::new('<', ::proc_macro::Spacing::Alone)
- ));
+ )]);
quote_spanned!(@proc $v $span $($tt)*);
};
(@proc $v:ident $span:ident > $($tt:tt)*) => {
- $v.push(::proc_macro::TokenTree::Punct(
+ $v.extend([::proc_macro::TokenTree::Punct(
::proc_macro::Punct::new('>', ::proc_macro::Spacing::Alone)
- ));
+ )]);
quote_spanned!(@proc $v $span $($tt)*);
};
(@proc $v:ident $span:ident == $($tt:tt)*) => {
- $v.push(::proc_macro::TokenTree::Punct(
+ $v.extend([::proc_macro::TokenTree::Punct(
::proc_macro::Punct::new('=', ::proc_macro::Spacing::Joint)
- ));
- $v.push(::proc_macro::TokenTree::Punct(
+ )]);
+ $v.extend([::proc_macro::TokenTree::Punct(
::proc_macro::Punct::new('=', ::proc_macro::Spacing::Alone)
- ));
+ )]);
quote_spanned!(@proc $v $span $($tt)*);
};
(@proc $v:ident $span:ident # $($tt:tt)*) => {
next prev parent reply other threads:[~2025-09-30 4:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-15 5:32 [PATCH v2 0/5] rust: add `TryFrom` and `Into` derive macros Jesung Yang
2025-08-15 5:32 ` [PATCH v2 1/5] rust: macros: allow conversion from `&T` to `TokenStream` Jesung Yang
2025-08-15 5:32 ` [PATCH v2 2/5] rust: macros: extend custom `quote!()` macro Jesung Yang
2025-08-28 6:39 ` Alice Ryhl
2025-08-28 7:14 ` Benno Lossin
2025-08-28 13:05 ` Alice Ryhl
2025-09-30 4:58 ` Alexandre Courbot [this message]
2025-09-30 7:17 ` Jesung Yang
2025-08-15 5:32 ` [PATCH v2 3/5] rust: macros: prefix variable `span` with underscore Jesung Yang
2025-08-15 5:32 ` [PATCH v2 4/5] rust: macros: add derive macro for `TryFrom` Jesung Yang
2025-08-15 5:32 ` [PATCH v2 5/5] rust: macros: add derive macro for `Into` Jesung Yang
2025-08-29 8:38 ` [PATCH v2 0/5] rust: add `TryFrom` and `Into` derive macros Alice Ryhl
2025-09-30 20:12 ` Miguel Ojeda
2025-10-10 10:07 ` Jesung Yang
2025-10-10 13:04 ` Miguel Ojeda
2025-10-11 14:53 ` Jesung Yang
2025-10-14 6:35 ` Alexandre Courbot
2025-11-03 0:18 ` Jesung Yang
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=DD5VAPG2QFWA.2A58AL13VHPN2@nvidia.com \
--to=acourbot@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=nouveau@lists.freedesktop.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=y.j3ms.n@gmail.com \
/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