Miri: Interpreter for Rust's mid-level intermediate representation
For a quick way to play with Miri, you can use the Rust playground [1]. Enter some code and then select Tools &gt; Miri.<p>As a starting example, here&#x27;s some code that Miri reports as violating Rust&#x27;s rules for references [2]:<p><pre><code>    fn main() {
        let mut i = 42;
        
        unsafe {
            let a = &amp;mut *(&amp;mut i as *mut _);
            let b = &amp;mut *(&amp;mut i as *mut _);
    
            println!(&quot;{:p}, {:p}&quot;, a, b);
        }
    }
</code></pre>
The output is:<p><pre><code>    error[E0080]: constant evaluation error: Borrow being dereferenced (Uniq(1797)) does not exist on the borrow stack
        --&gt; &#x2F;root&#x2F;.rustup&#x2F;toolchains&#x2F;nightly-x86_64-unknown-linux-gnu&#x2F;lib&#x2F;rustlib&#x2F;src&#x2F;rust&#x2F;src&#x2F;libcore&#x2F;fmt&#x2F;mod.rs:2050:24
         |
    2050 |         Pointer::fmt(&amp;(&amp;**self as *const T), f)
         |                        ^^^^^^^ Borrow being dereferenced (Uniq(1797)) does not exist on the borrow stack
         |
         = note: inside call to `&lt;&amp;mut i32 as std::fmt::Pointer&gt;::fmt` at &#x2F;root&#x2F;.rustup&#x2F;toolchains&#x2F;nightly-x86_64-unknown-linux-gnu&#x2F;lib&#x2F;rustlib&#x2F;src&#x2F;rust&#x2F;src&#x2F;libcore&#x2F;fmt&#x2F;mod.rs:1016:17
         = note: inside call to `std::fmt::write` at &#x2F;root&#x2F;.rustup&#x2F;toolchains&#x2F;nightly-x86_64-unknown-linux-gnu&#x2F;lib&#x2F;rustlib&#x2F;src&#x2F;rust&#x2F;src&#x2F;libstd&#x2F;io&#x2F;mod.rs:1266:15
         = note: inside call to `&lt;std::io::StdoutLock as std::io::Write&gt;::write_fmt` at &#x2F;root&#x2F;.rustup&#x2F;toolchains&#x2F;nightly-x86_64-unknown-linux-gnu&#x2F;lib&#x2F;rustlib&#x2F;src&#x2F;rust&#x2F;src&#x2F;libstd&#x2F;io&#x2F;stdio.rs:493:9
         = note: inside call to `&lt;std::io::Stdout as std::io::Write&gt;::write_fmt` at &#x2F;root&#x2F;.rustup&#x2F;toolchains&#x2F;nightly-x86_64-unknown-linux-gnu&#x2F;lib&#x2F;rustlib&#x2F;src&#x2F;rust&#x2F;src&#x2F;libstd&#x2F;io&#x2F;stdio.rs:737:9
         = note: inside call to closure at &#x2F;root&#x2F;.rustup&#x2F;toolchains&#x2F;nightly-x86_64-unknown-linux-gnu&#x2F;lib&#x2F;rustlib&#x2F;src&#x2F;rust&#x2F;src&#x2F;libstd&#x2F;thread&#x2F;local.rs:299:16
         = note: inside call to `std::thread::LocalKey::&lt;std::cell::RefCell&lt;std::option::Option&lt;std::boxed::Box&lt;dyn std::io::Write + std::marker::Send&gt;&gt;&gt;&gt;::try_with::&lt;[closure@DefId(1&#x2F;1:1025 ~ std[82ff]::io[0]::stdio[0]::print_to[0]::{{closure}}[0]) 0:&amp;std::fmt::Arguments, 1:&amp;fn() -&gt; std::io::Stdout], std::result::Result&lt;(), std::io::Error&gt;&gt;` at &#x2F;root&#x2F;.rustup&#x2F;toolchains&#x2F;nightly-x86_64-unknown-linux-gnu&#x2F;lib&#x2F;rustlib&#x2F;src&#x2F;rust&#x2F;src&#x2F;libstd&#x2F;io&#x2F;stdio.rs:731:18
         = note: inside call to `std::io::stdio::print_to::&lt;std::io::Stdout&gt;` at &#x2F;root&#x2F;.rustup&#x2F;toolchains&#x2F;nightly-x86_64-unknown-linux-gnu&#x2F;lib&#x2F;rustlib&#x2F;src&#x2F;rust&#x2F;src&#x2F;libstd&#x2F;io&#x2F;stdio.rs:753:5
    note: inside call to `std::io::_print` at &lt;::std::macros::println macros&gt;:2:3
        --&gt; src&#x2F;main.rs:8:9
         |
    8    |         println!(&quot;{:p}, {:p}&quot;, a, b);
         |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         = note: inside call to `main` at &#x2F;root&#x2F;.rustup&#x2F;toolchains&#x2F;nightly-x86_64-unknown-linux-gnu&#x2F;lib&#x2F;rustlib&#x2F;src&#x2F;rust&#x2F;src&#x2F;libstd&#x2F;rt.rs:64:34
         = note: inside call to closure at &#x2F;root&#x2F;.rustup&#x2F;toolchains&#x2F;nightly-x86_64-unknown-linux-gnu&#x2F;lib&#x2F;rustlib&#x2F;src&#x2F;rust&#x2F;src&#x2F;libstd&#x2F;rt.rs:52:53
         = note: inside call to closure at &#x2F;root&#x2F;.rustup&#x2F;toolchains&#x2F;nightly-x86_64-unknown-linux-gnu&#x2F;lib&#x2F;rustlib&#x2F;src&#x2F;rust&#x2F;src&#x2F;libstd&#x2F;panicking.rs:293:40
         = note: inside call to `std::panicking::try::do_call::&lt;[closure@DefId(1&#x2F;1:1830 ~ std[82ff]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&amp;dyn std::ops::Fn() -&gt; i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32&gt;` at &#x2F;root&#x2F;.rustup&#x2F;toolchains&#x2F;nightly-x86_64-unknown-linux-gnu&#x2F;lib&#x2F;rustlib&#x2F;src&#x2F;rust&#x2F;src&#x2F;libstd&#x2F;panicking.rs:289:5
         = note: inside call to `std::panicking::try::&lt;i32, [closure@DefId(1&#x2F;1:1830 ~ std[82ff]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&amp;dyn std::ops::Fn() -&gt; i32 + std::marker::Sync + std::panic::RefUnwindSafe]&gt;` at &#x2F;root&#x2F;.rustup&#x2F;toolchains&#x2F;nightly-x86_64-unknown-linux-gnu&#x2F;lib&#x2F;rustlib&#x2F;src&#x2F;rust&#x2F;src&#x2F;libstd&#x2F;panic.rs:388:9
         = note: inside call to `std::panic::catch_unwind::&lt;[closure@DefId(1&#x2F;1:1830 ~ std[82ff]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&amp;dyn std::ops::Fn() -&gt; i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32&gt;` at &#x2F;root&#x2F;.rustup&#x2F;toolchains&#x2F;nightly-x86_64-unknown-linux-gnu&#x2F;lib&#x2F;rustlib&#x2F;src&#x2F;rust&#x2F;src&#x2F;libstd&#x2F;rt.rs:52:25
         = note: inside call to `std::rt::lang_start_internal` at &#x2F;root&#x2F;.rustup&#x2F;toolchains&#x2F;nightly-x86_64-unknown-linux-gnu&#x2F;lib&#x2F;rustlib&#x2F;src&#x2F;rust&#x2F;src&#x2F;libstd&#x2F;rt.rs:64:5
         = note: inside call to `std::rt::lang_start::&lt;()&gt;`
         = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

</code></pre>
[1]: <a href="https:&#x2F;&#x2F;play.rust-lang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;play.rust-lang.org&#x2F;</a><p>[2]: <a href="https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;stable&#x2F;book&#x2F;ch04-02-references-and-borrowing.html#the-rules-of-references" rel="nofollow">https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;stable&#x2F;book&#x2F;ch04-02-references-and...</a>