All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>
Cc: <gregkh@linuxfoundation.org>, <rafael@kernel.org>,
	<ojeda@kernel.org>, <boqun@kernel.org>, <gary@garyguo.net>,
	<bjorn3_gh@protonmail.com>, <lossin@kernel.org>,
	<a.hindborg@kernel.org>, <aliceryhl@google.com>,
	<tmgross@umich.edu>, <acourbot@nvidia.com>,
	<ecourtney@nvidia.com>, <m.wilczynski@samsung.com>,
	<david.m.ertman@intel.com>, <ira.weiny@intel.com>,
	<leon@kernel.org>, <daniel.almeida@collabora.com>,
	<bhelgaas@google.com>, <kwilczynski@kernel.org>,
	<driver-core@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
	<nova-gpu@lists.linux.dev>, <dri-devel@lists.freedesktop.org>,
	<linux-pwm@vger.kernel.org>, <rust-for-linux@vger.kernel.org>
Subject: Re: [PATCH v4 2/7] rust: types: introduce ForLt base trait for CovariantForLt
Date: Sat, 27 Jun 2026 15:51:23 +0200	[thread overview]
Message-ID: <DJJVPW8H183T.1927SIBS40Z40@kernel.org> (raw)
In-Reply-To: <CANiq72=0OOgc6NtbpF0Ysdk3ytRWCGGbWg00u0Le2AzQmKGKxg@mail.gmail.com>

On Sat Jun 27, 2026 at 2:26 PM CEST, Miguel Ojeda wrote:
> If this goes in at the same time as the move (as I assume), then am I
> understanding it right that if someone else was using `ForLt`
> (trait/macro) things would either break at compile-time (which is OK)
> or, in the covariant type case with no `cast_ref()`, it would build,
> but someone could in principle have relied on `ForLt` providing the
> covariance guarantee in unsafe code?

If someone would have unsafely asserted covariance for ForLt it would break at
compile-time like this:

	error[E0199]: implementing the trait `types::for_lt::ForLt` is not unsafe
	   --> rust/kernel/pci/io.rs:158:1
	    |
	158 | unsafe impl<const SIZE: usize> ForLt for Bar<'static, SIZE> {
	    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	    |
	help: remove `unsafe` from this trait implementation
	    |
	158 - unsafe impl<const SIZE: usize> ForLt for Bar<'static, SIZE> {
	158 + impl<const SIZE: usize> ForLt for Bar<'static, SIZE> {
	    |
	
	error: aborting due to 1 previous error

The only way this could silently break would be to use ForLt!(), but then don't
use the explicitly provided safe cast_ref() method, and instead open-code it
with an unsafe transmute() assuming covariance from ForLt!().

Even though very unlikely, I do however have an eye on whether another user of
this API appears.

(The whole series also goes into a topic branch based on -rc1 anyway, so I can
also always provide a signed tag with just patch 1 and 2 based on -rc1 should
the need arise.)

> Acked-by: Miguel Ojeda <ojeda@kernel.org>

Thanks!

> We could take the chance to add some missing intra-doc links, but I
> can add a good first issue.

I can add them on apply, or we leave them as good first issue, as you prefer.

Thanks,
Danilo

  reply	other threads:[~2026-06-27 13:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26 18:36 [PATCH v4 0/7] ForLt/CovariantForLt split, auxiliary closure API and DevresLt Danilo Krummrich
2026-06-26 18:36 ` [PATCH v4 1/7] rust: types: rename ForLt to CovariantForLt Danilo Krummrich
2026-06-27 10:59   ` Miguel Ojeda
2026-06-26 18:36 ` [PATCH v4 2/7] rust: types: introduce ForLt base trait for CovariantForLt Danilo Krummrich
2026-06-27 12:26   ` Miguel Ojeda
2026-06-27 13:51     ` Danilo Krummrich [this message]
2026-06-27 14:21       ` Miguel Ojeda
2026-06-26 18:36 ` [PATCH v4 3/7] rust: auxiliary: add registration_data_with() for ForLt types Danilo Krummrich
2026-06-26 18:36 ` [PATCH v4 4/7] rust: auxiliary: sample: demonstrate ForLt with invariant Mutex type Danilo Krummrich
2026-06-26 18:36 ` [PATCH v4 5/7] rust: devres: add DevresLt for ForLt-aware device resource access Danilo Krummrich
2026-06-26 18:50   ` sashiko-bot
2026-06-26 18:36 ` [PATCH v4 6/7] rust: pci: return DevresLt from Bar::into_devres() Danilo Krummrich
2026-06-26 18:46   ` sashiko-bot
2026-06-26 18:36 ` [PATCH v4 7/7] rust: io: mem: return DevresLt from IoMem/ExclusiveIoMem::into_devres() 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=DJJVPW8H183T.1927SIBS40Z40@kernel.org \
    --to=dakr@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=bhelgaas@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=david.m.ertman@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=driver-core@lists.linux.dev \
    --cc=ecourtney@nvidia.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=ira.weiny@intel.com \
    --cc=kwilczynski@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=m.wilczynski@samsung.com \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=nova-gpu@lists.linux.dev \
    --cc=ojeda@kernel.org \
    --cc=rafael@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.