Ariel Ben-Yehuda
Ariel Ben-Yehuda
We need to make some call around this for parity with AST borrowck - AST borrowck allows this sort of thing.
@RalfJung You (or @nikomatsakis's somewhat- description) are off-by-one-layer-of-indirection. The idea is that *borrows of dereferences of dangly pointers* remain valid after the destructor runs, *not* that borrows of dangly things...
> (To be clear, in the example that @arielb1 added, the drop is something more like std::mem::drop(inner_ref), and not the MIR drop operation. Or else I am confused.) Sure, because...
> This is roughly the same analyses that we do for drop elaboration, right? I was wondering if it would make sense to think about separating out the initialization analysis...
@nikomatsakis Sure.
@nikomatsakis I had some odd dataflow-ish solution in mind, which I could try to write in more detail. I *believe* it means we can do this sanely in a sane...
But there is a delayed start - a lifetime constraint only applies when it is evaluated.
@eddyb Automatic boxing by the compiler feels weird to me (it occurs *only* in this special case), and people will do `MyRef::new(x.clone(), do_xyz()?)`, which feels like it would require autoboxing...