So conceptually I don't see why you couldn't compile a rust compiler to wasm and use some javascript glue code to load your new on the fly compiled wasm modules. Practically I can't imagine this being an appropriate solution for your task. If you want a general purpose Rust compiler you'd have to send hundreds of megabytes just for that functionality. Are you asking this out of general curiosity, or do you have some specific problem you want to solve?
Ah, I should clarify, I'm not asking for, at runtime, a "rustc -> wasm" compiler.
I'm asking for a "some restricted set of instructions -> wasm" dynamic code generator. Even a "c -> wasm" or "mips -> wasm" or "sorta x86 -> wasm" would be fine. The part I need is all the glue that takes the wast, loads it as a module, dynamically loads it, and calls the function ...