3 ms·
I'll assume you meant 'ref = &x' in your example. But what happens is that variables leave scope in reverse of the order in which they came in, so ref lives fo
by koenigdavidmj 11y ago
I'll assume you meant 'ref = &x' in your example.
But what happens is that variables leave scope in reverse of the order in which they came in, so ref lives for slightly longer than val.
This happens so that the order of destructors can be guaranteed.
- borrowwhatnow 11y ago> I'll assume you meant 'ref = &x' in your example. I did, thanks.
- Veedrac 11y agorefs don't have destructors. This happens because borrow scopes are always lexical. This is a bug, see https://github.com/rust-lang/rfcs/issues/811 https://github.com/rust-lang/rfcs/issues/811.
- nightpool 11y agoBug =/= language feature that we want that hasn't been implemented or designed yet, FWIW. Right now the borrow checker is currently performing to spec, but the spec is just a little too restrictive in some cases.
- Jweb_Guru 11y ago"Bug =/= language feature that we want that hasn't been implemented or designed yet, FWIW." In this case, I think the term is justified.
- IsTom 11y agoHonestly in my experience it's a deal-breaking bug. It's so awfully crippled compared to DDC regions.