@WatsonJX, it doesn’t sound like you’re looking for a debugger, but instead are looking for a REPL.
There is already such a project, rusti. It’s fairly young, but it does most of what you ask for. Here’s a sample session, where I forgot the return type the first time:
$ cargo run
Running `target/debug/rusti`
rusti=> fn factorial(x: i64) {
rusti.> match x {
rusti.> 0 => 0,
rusti.> 1 => 1,
rusti.> _ => x * factorial(x - 1)
rusti.> }
rusti.> }
<anon>:9:14: 9:34 error: type mismatch resolving `<i64 as core::ops::Mul<()>>::Output == _`:
expected type error,
found integral variable [E0271]
<anon>:9 _ => x * factorial(x - 1)
^~~~~~~~~~~~~~~~~~~~
<anon>:9:14: 9:34 help: run `rustc --explain E0271` to see a detailed explanation
<anon>:9:14: 9:34 error: the trait `core::ops::Mul<()>` is not implemented for the type `i64` [E0277]
<anon>:9 _ => x * factorial(x - 1)
^~~~~~~~~~~~~~~~~~~~
<anon>:9:14: 9:34 error: the trait `core::ops::Mul<()>` is not implemented for the type `i64` [E0277]
<anon>:9 _ => x * factorial(x - 1)
^~~~~~~~~~~~~~~~~~~~
<anon>:6:5: 10:6 error: mismatched types:
expected `()`,
found `_`
(expected (),
found integral variable) [E0308]
<anon>:6 match x {
<anon>:7 0 => 0,
<anon>:8 1 => 1,
<anon>:9 _ => x * factorial(x - 1)
<anon>:10 }
<anon>:6:5: 10:6 help: run `rustc --explain E0308` to see a detailed explanation
error: aborting due to 4 previous errors
rusti=> fn factorial(x: i64) -> i64 {
rusti.> match x {
rusti.> 0 => 0,
rusti.> 1 => 1,
rusti.> _ => x * factorial(x - 1)
rusti.> }
rusti.> }
rusti=> factorial(10)
3628800
rusti=>