[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <D8ORYL7ZZG8R.1LEAYI5807G9H@proton.me>
Date: Mon, 24 Mar 2025 20:22:20 +0000
From: Benno Lossin <benno.lossin@...ton.me>
To: Daniel Almeida <daniel.almeida@...labora.com>, Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>, Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>, Björn Roy Baron <bjorn3_gh@...tonmail.com>, Andreas Hindborg <a.hindborg@...nel.org>, Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>, Sumit Semwal <sumit.semwal@...aro.org>, Christian König <christian.koenig@....com>, Boris Brezillon <boris.brezillon@...labora.com>, linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org, dri-devel@...ts.freedesktop.org, Asahi Lina <lina@...hilina.net>
Subject: Re: [PATCH 2/2] rust: drm: Add GPUVM abstraction
On Mon Mar 24, 2025 at 8:25 PM CET, Daniel Almeida wrote:
>> On 24 Mar 2025, at 14:36, Miguel Ojeda <miguel.ojeda.sandonis@...il.com> wrote:
>>
>> Hi Daniel,
>>
>> A few quick notes for future versions on style/docs to try to keep
>> things consistent upstream -- not an actual review.
>>
>> On Mon, Mar 24, 2025 at 4:14 PM Daniel Almeida
>> <daniel.almeida@...labora.com> wrote:
>>>
>>> +#[allow(type_alias_bounds)]
>>
>> The documentation says this is highly discouraged -- it may be good to
>> mention why it is OK in this instance in a comment or similar.
>
> Someone correct me here, but I see no issue with this warning. That’s
> because we need the bound to make `<T::Driver as drv::Driver>` work in the
> first place. Otherwise, we’d get a compiler error saying that there’s
> no `Driver` associated type (assuming the case where a random T gets
> passed in)
>
> So, for this to be a problem, we would need to mix this up with something that
> also has a `Driver` associated type, and this associated type would also need a
> drv::Driver bound.
>
> In other words, we would need a lot of things to align for this to actually
> have a chance of being misused. When you consider that this is then only used
> in a few places, the balance tips heavily in favor of the convenience of having
> the type alias IMHO.
>
> In fact, the docs point to the exact thing I am trying to do, i.e.:
>
>> these bounds may have secondary effects such as enabling the use of “shorthand” associated type paths
>
>> I.e., paths of the form T::Assoc where T is a type parameter bounded by trait Trait which defines an associated type called Assoc as opposed to a fully qualified path of the form <T as Trait>::Assoc.
You can avoid the allow by using:
type DriverObject<T> = <<T as DriverGpuVm>::Driver as drv::Driver>::Object;
That is more wordy, but avoids the allow (it still errors when you put
in something that doesn't implement `DriverGpuVm`).
---
Cheers,
Benno
Powered by blists - more mailing lists