Still that assert has to be checked at some point right? I would assume that maybe the compiler could do this optimization without having to be told.
However, I believe a future Rust RFC could turn that around and validate the idea that in some cases such things could change execution order, even if it has noticeable side effects.
(No idea if it's technically feasible!)