3 ms·
>While we are many missing language features away from this being the case, the noalias case is also magic descended upon box itself, with no user code ever hav
by landr0id 2y ago
>While we are many missing language features away from this being the case, the noalias case is also magic descended upon box itself, with no user code ever having access to it.
I'm not sure why the author thinks there's magic behind Box. Box is not a special case of `noalias`. Run this snippet with miri and you'll see the same issue: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=fd0e3f8c641683c5949847c16f2f08ea https://play.rust-lang.org/?version=stable&mode=debug&editio...
You don't see an assertion failure though because... dun dun dun it's UB.
`Box<T>` _does_ have an expectation that its inner pointer is not aliased to another Box (even if used for readonly operations). See: https://github.com/rust-lang/miri/issues/1800#issuecomment-841796375 https://github.com/rust-lang/miri/issues/1800#issuecomment-8...)
- deleted 2y ago[deleted]
- panstromek 2y agoWell, they work on the compiler, so that's one reason I guess. Also the fact that it's magic is no secret and this is not the only way in which it is (the most important is probably the DerefMove behaviour that's mentioned in the article, too). There's been many discussions around this in the past