3 ms·
You can track some of the history of the proposals here: https://github.com/rust-lang/rust/issues/29722 https://github.com/rust-lang/rust/issues/29722. A lot o
by jcranmer 6y ago
You can track some of the history of the proposals here: https://github.com/rust-lang/rust/issues/29722 https://github.com/rust-lang/rust/issues/29722.
A lot of the improvements you've suggested have been suggested in the past, but there's some reasons why they aren't being proposed. In short, sufficiently smart compilers can probably guess at a lot of constraints automatically, but building that level of smarts is very daunting, and for most use cases, the user probably wants/needs the fine-grained control anyways.
For example, take the call instruction. Which registers should the compiler mark that as using and/or clobbering? It depends on the ABI of the function being called--and the user might not even be calling a function at all (say, using a call as a gadget to get the current program counter). Saving a register is another common technique in inline assembly, and you don't want the compiler to infer that the register is clobbered--indeed you're saving it to explicitly not clobber it.
- lilyball 6y agoCould we build a sufficiently smart compiler as a procedural macro that wraps asm!(), so it can be developed as part of the ecosystem?
- jfkebwjsbx 6y agoThat’s a very perilous road. Not to mention expensive to maintain, slow to compile, with very little gain.
- lilyball 6y agoAll of that would be true if the compiler had it built-in too though, right?