Compiling another language to Rust's HIR?

I would like to exploring compiling another language to Rust's HIR to taken advantage of all of Rust's memory and type safety. Has anyone done this before ? Suggestions and references would be quite welcome. Thank you

Compiling to Rust, instead of Rust's HIR has two advantages:

  1. You don't have to depend on compiler internals, so it will keep working forever instead of breaking every once in a while.
  2. It is much simpler.

If you still want to do this, you will have to implement something similar to rustc_ast_lowering::lower_crate and then either modify rustc_interface::passes::lower_to_hir to call it, or modify a copy and transitively modify copies of all functions that call it.


Thank you. I will explore both approaches.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.