public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
	"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>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: alloc: allow coercion from `Box<T>` to `Box<dyn U>` if T implements U
Date: Tue, 08 Apr 2025 22:19:12 +0900	[thread overview]
Message-ID: <D91ACTUAWQTF.2AZ98BUA5ZKJ6@nvidia.com> (raw)
In-Reply-To: <CANiq72k9Lo-M5v338iWWSiwrnU+JwP+aEZeLiR291xc2c+ESOg@mail.gmail.com>

On Tue Apr 8, 2025 at 7:35 PM JST, Miguel Ojeda wrote:
> On Tue, Apr 8, 2025 at 12:22 PM Benno Lossin <benno.lossin@proton.me> wrote:
>>
>> You forgot to add the `A: Allocator` generic here and in the impl below.
>
> Yeah, for this sort of changes (ideally, all patches, really), please
> test with both the minimum supported version and the latest.

Apologies for that, I had no idea how to build using a specific
toolchain and did the wrong thing, which is sending without proper
testing.

I had some trouble finding how to 1) find out the minimum supported Rust
version, and 2) how to build using a specific toolchain.

For 1) I eventually found a hardcoded version in
scripts/min-tool-version.sh ; and 2) is somehow documentated in the
Quick Start guide that mentions the `rustup override set stable`
command.

I can send a patch against the Coding Guidelines adding a section to
encourage testing against the minimum version and explain how to force a
specific Rust version if you can confirm this would be helpful (and that
min-tool-version.sh is the correct way to check the minimum supported
Rust version).

>
> For instance, there is another issue, `#[pointee]` is only applicable
> when you have the feature:
>
>     error: cannot find attribute `pointee` in this scope
>      --> rust/kernel/alloc/kbox.rs:66:18
>       |
>     66 | pub struct Box<#[pointee] T: ?Sized, A:
> Allocator>(NonNull<T>, PhantomData<A>);

Mmm that one is trickier to address - I don't know of a way to make this
`#[pointee]` attribute depedent on `CONFIG_RUSTC_HAS_COERCE_POINTEE`...
Only solution I see if having two separate declarations for `Box`, and
then we have the problem of bindings the rustdoc to the declaration that
is picked at build time... Any idea for how to best address this?

Thanks,
Alex.


  reply	other threads:[~2025-04-08 13:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-08  5:18 [PATCH] rust: alloc: allow coercion from `Box<T>` to `Box<dyn U>` if T implements U Alexandre Courbot
2025-04-08 10:22 ` Benno Lossin
2025-04-08 10:35   ` Miguel Ojeda
2025-04-08 13:19     ` Alexandre Courbot [this message]
2025-04-08 13:40       ` Alice Ryhl
2025-04-08 13:55         ` Alexandre Courbot
2025-04-08 13:58       ` Miguel Ojeda
2025-04-11 12:01         ` Alexandre Courbot
2025-04-08 13:03   ` Danilo Krummrich

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=D91ACTUAWQTF.2AZ98BUA5ZKJ6@nvidia.com \
    --to=acourbot@nvidia.com \
    --cc=a.hindborg@kernel.org \
    --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=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /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