nikomatsakis / borrowck

Modeling NLL and the Rust borrowck
Apache License 2.0
75 stars 12 forks source link

Dangly paths #17

Open pnkfelix opened 6 years ago

pnkfelix commented 6 years ago

The feature being implemented here is sketched out in https://gist.github.com/pnkfelix/6df6975c99d5c4da37136ada9fa44fb0

(I still need to transcribe part of the comments in this code into that gist, analogous to the Detailed Design of an RFC.)

RalfJung commented 6 years ago

@nikomatsakis sent me here during the recent #[may_dangle] discussion. TIL we have another soundness hole. ;)

I have one question regarding the gist you referenced:

Now, even though the destructor of MessageOnDrop2 does not access its type parameter, dropping it still drops the instance of T, which for eventually_impure means that we run the destructor of PoisonOnDrop (and thus mutate data in the reference).

So we need to be careful.

This "just" means that we have to check all the types along the path in question, right? If things are done properly structurally, recursing over the type, this should just work? Or am I missing something?