lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260108152408.2aeb10f7.gary@garyguo.net>
Date: Thu, 8 Jan 2026 15:24:08 +0000
From: Gary Guo <gary@...yguo.net>
To: Tamir Duberstein <tamird@...il.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Boqun Feng <boqun.feng@...il.com>,
 Björn Roy Baron <bjorn3_gh@...tonmail.com>, Benno Lossin
 <lossin@...nel.org>, Andreas Hindborg <a.hindborg@...nel.org>, Alice Ryhl
 <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>, Danilo Krummrich
 <dakr@...nel.org>, Igor Korotin <igor.korotin.linux@...il.com>,
 José Expósito <jose.exposito89@...il.com>,
 rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 03/11] rust: macros: convert `#[vtable]` macro to use
 `syn`

On Thu, 8 Jan 2026 10:10:23 -0500
Tamir Duberstein <tamird@...il.com> wrote:

> > > > +    let mut consts = HashSet::new();
> > > > +    for name in functions {
> > > > +        let gen_const_name = Ident::new(
> > > > +            &format!("HAS_{}", name.to_string().to_uppercase()),
> > > > +            name.span(),
> > > > +        );
> > > > +        // Skip if it's declared already -- this can happen if `#[cfg]` is used to selectively
> > > > +        // define functions.
> > > > +        // FIXME: `#[cfg]` should be copied and propagated to the generated consts.
> > > > +        if consts.contains(&gen_const_name) {
> > > > +            continue;
> > > > +        }
> > > > +        // We don't know on the implementation-site whether a method is required or provided
> > > > +        // so we have to generate a const for all methods.
> > > > +        let comment = format!("Indicates if the `{name}` method is overridden by the implementor.");  
> > >
> > > We're already quasi-quoting below, does putting the comment there work?  
> >
> > The comment has `{name}` interpolation and you cannot just use `quote!`
> > for it.
> >
> > You could do
> >
> >         #[doc = concat!("...", stringify!(...), "...")]
> >
> > But I think it's cleaner to just use `format!`.  
> 
> Ack, though I think it would be:
> 
> #[doc = concat!("Indicates if the `", #name, "` method is overridden
> by the implementor.")]
> 
> i.e. no need for `stringify`.

Note `name` here is an `Ident`, which gets turned into an identifer, not a
string, so if `concat!` is used stringify is still necessary.

Anyway, I'm going to keep `format!` in the new version.

Best,
Gary

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ