I've been writing a small Rust program compiled to WebAssembly that draws stuff in a circle, it uses cosine and sine to work out the X and Y coords to draw on a <canvas>. It worked fine until I added controls for the position on the circle to draw at, at which point it started failing to load because it was missing an implementation for cosine and sine

eventually I figured out that when I had hardcoded the position as a constant before, the compiler was optimising out all the calculations, including calls to cos() and sin() and replacing them with their results at compile time, so had no need for runtime implementations until I made the position a variable 😂