Thread (27 messages) 27 messages, 3 authors, 2025-03-27

Re: [PATCH v7 7/7] rust: enable `clippy::ref_as_ptr` lint

From: Benno Lossin <hidden>
Date: 2025-03-26 22:15:53
Also in: dri-devel, linux-block, linux-devicetree, linux-kbuild, linux-kselftest, linux-pci, lkml, rust-for-linux

On Wed Mar 26, 2025 at 11:09 PM CET, Tamir Duberstein wrote:
On Wed, Mar 26, 2025 at 5:09 PM Benno Lossin [off-list ref] wrote:
quoted
On Wed Mar 26, 2025 at 8:06 PM CET, Tamir Duberstein wrote:
quoted
On Wed, Mar 26, 2025 at 1:36 PM Benno Lossin [off-list ref] wrote:
quoted
On Wed Mar 26, 2025 at 5:57 PM CET, Tamir Duberstein wrote:
quoted
Yeah, we should do this - but again: not relevant in this discussion.
I think it's pretty relevant.
It's not relevant because we're no longer talking about transmuting
pointer to pointer. The two options are:
1. transmute reference to reference.
2. coerce reference to pointer, `as` cast pointer to pointer (triggers
`ptr_as_ptr`), reborrow pointer to reference.

If anyone can help me understand why (2) is better than (1), I'd
certainly appreciate it.
I am very confident that (2) is correct. With (1) I'm not sure (see
above), so that's why I mentioned it.
Can you help me understand why you're confident about (2) but not (1)?
My explanation from above explains why I'm not confident about (1):

    For ptr-to-int transmutes, I know that they will probably remove
    provenance, hence I am a bit cautious about using them for ptr-to-ptr or
    ref-to-ref.

The reason I'm confident about (2) is that that is the canonical way to
cast the type of a reference pointing to an `!Sized` value.

---
Cheers,
Benno
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help