Stream: general

Topic: Understanding PhantomData and dropchk


Elichai Turkel (May 11 2020 at 19:47, on Zulip):

Hi, I'm trying to understand the usage of PhantomData to tell dropck that we "own T" I easily see the usage for PhantomData in lifetimes, but not here I read the comment above this: https://github.com/rust-lang/rust/blob/master/src/libcore/ptr/unique.rs#L45, the link, the nomicon sections about dropchk+PhantomData
and still don't get it.
Any explanations/examples are welcome :)

Lokathor (May 11 2020 at 20:01, on Zulip):

I believe it's because the dropcheck goes "outside in", if i'm reading the RFC linked to by that comment correctly.

zeroexcuses (May 11 2020 at 20:45, on Zulip):

EDIT: I misunderstood the question.

Jonas Schievink (May 11 2020 at 20:47, on Zulip):

No, it would still compile. That use of PhantomData is purely for dropck, as the comment indicates.

zeroexcuses (May 11 2020 at 20:48, on Zulip):

Ah, does

    // NOTE: this marker has no consequences for variance, but is necessary
    // for dropck to understand that we logically own a `T`.

invalidate my claims (i.e. the "no consequence for variance" part).

zeroexcuses (May 11 2020 at 21:43, on Zulip):

I read https://doc.rust-lang.org/nomicon/dropck.html a few times. I understand the importance of Generic arguments strictly out living a type. what I don't understand now is -- how does this related to the Unique<T> example above?

Last update: Jun 05 2020 at 22:40UTC