From: Gary Guo <gary@garyguo.net>
To: Benno Lossin <benno.lossin@proton.me>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Wedson Almeida Filho" <wedsonaf@gmail.com>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Andreas Hindborg" <nmi@metaspace.dk>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@lists.linux.dev, "Asahi Lina" <lina@asahilina.net>
Subject: Re: [PATCH 7/7] rust: init: add support for arbitrary paths in init macros
Date: Wed, 28 Jun 2023 18:13:59 +0100 [thread overview]
Message-ID: <20230628181359.54fa03d7.gary@garyguo.net> (raw)
In-Reply-To: <u8Hy97tvl2TFqYO2rZch21iVBAAH7Cqe_ONBp7B35wE6QnevIyABIWgaGrZcA1NZ3rcr0m_K-RzVfiiycccX0UACcTx-pMF94CiGxT-auYM=@proton.me>
On Wed, 28 Jun 2023 11:26:54 +0000
Benno Lossin <benno.lossin@proton.me> wrote:
> On 25.06.23 23:01, Gary Guo wrote:
> > On Sat, 24 Jun 2023 09:25:39 +0000
> > Benno Lossin <benno.lossin@proton.me> wrote:
> >
> >> Previously only `ident` and generic types were supported in the
> >> `{try_}{pin_}init!` macros. This patch allows arbitrary path fragments,
> >> so for example `Foo::Bar` but also very complex paths such as
> >> `<Foo as Baz>::Bar::<0, i32>`.
> >>
> >> Internally this is accomplished by using `path` fragments. Due to some
> >> peculiar declarative macro limitations, we have to "forget" certain
> >> additional parsing information in the token trees. This is achieved by
> >> the new `retokenize` proc macro. It does not modify the input, but just
> >> strips this information. For example, if a declarative macro takes
> >> `$t:path` as its input, it cannot sensibly propagate this to a macro that
> >> takes `$($p:tt)*` as its input, since the `$t` token will only be
> >> considered one `tt` token for the second macro. If we first pipe the
> >> tokens through `retokenize`, then it parses as expected.
> >
> > I think this "retokenize" macro could also be functionally replaced by
> > `paste`. Would you mind to apply my paste patch (referenced in a
> > previous email) and see if it works?
>
> I tried your patch and it seems to work. I also executed all of the test
> in the userspace library and they passed.
> The `paste!` code also looks good to me. One thing that I thought was this:
> do we want to accept `paste!( [<= foo bar>])`? Because the `<` token has
> spacing `Joint`, maybe add a check for that? No idea if that would be a problem.
>
I don't think checking that is necessary, since that wouldn't be
valid Rust anyway?
Best,
Gary
next prev parent reply other threads:[~2023-06-28 17:14 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-24 9:24 [PATCH 1/7] rust: init: consolidate init macros Benno Lossin
2023-06-24 9:25 ` [PATCH 2/7] rust: add derive macro for `Zeroable` Benno Lossin
2023-06-24 14:55 ` Björn Roy Baron
2023-06-25 20:46 ` Gary Guo
2023-07-03 11:50 ` Alice Ryhl
2023-06-24 9:25 ` [PATCH 3/7] rust: init: make guards in the init macros hygienic Benno Lossin
2023-06-24 14:58 ` Björn Roy Baron
2023-06-25 20:54 ` Gary Guo
2023-06-28 11:41 ` Benno Lossin
2023-06-28 16:48 ` Gary Guo
2023-06-24 9:25 ` [PATCH 4/7] rust: init: wrap type checking struct initializers in a closure Benno Lossin
2023-06-24 15:03 ` Björn Roy Baron
2023-06-24 21:05 ` Benno Lossin
2023-06-24 9:25 ` [PATCH 5/7] rust: init: add `..Zeroable::zeroed()` syntax for zeroing all missing fields Benno Lossin
2023-06-24 15:11 ` Björn Roy Baron
2023-06-24 21:14 ` Benno Lossin
2023-06-25 12:56 ` Björn Roy Baron
2023-06-25 13:07 ` Benno Lossin
2023-06-25 14:17 ` Björn Roy Baron
2023-06-25 16:46 ` Benno Lossin
2023-07-03 11:58 ` Alice Ryhl
2023-07-03 18:15 ` Boqun Feng
2023-07-05 17:48 ` Gary Guo
2023-07-05 21:44 ` Benno Lossin
2023-06-24 9:25 ` [PATCH 6/7] rust: init: Add functions to create array initializers Benno Lossin
2023-06-24 15:17 ` Björn Roy Baron
2023-07-03 12:03 ` Alice Ryhl
2023-06-24 9:25 ` [PATCH 7/7] rust: init: add support for arbitrary paths in init macros Benno Lossin
2023-06-24 15:20 ` Björn Roy Baron
2023-06-25 21:01 ` Gary Guo
2023-06-28 11:26 ` Benno Lossin
2023-06-28 17:13 ` Gary Guo [this message]
2023-06-24 14:49 ` [PATCH 1/7] rust: init: consolidate " Björn Roy Baron
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=20230628181359.54fa03d7.gary@garyguo.net \
--to=gary@garyguo.net \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=lina@asahilina.net \
--cc=linux-kernel@vger.kernel.org \
--cc=nmi@metaspace.dk \
--cc=ojeda@kernel.org \
--cc=patches@lists.linux.dev \
--cc=rust-for-linux@vger.kernel.org \
--cc=wedsonaf@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;
as well as URLs for NNTP newsgroup(s).