@@ -83,31 +83,32 @@ determine a nightly version that comes with Miri and install that using
8383
8484Now you can run your project in Miri:
8585
86- 1 . Run ` cargo clean ` to eliminate any cached dependencies. Miri needs your
86+ 1 . Run ` cargo clean ` to eliminate any cached dependencies. Miri needs your
8787 dependencies to be compiled the right way, that would not happen if they have
8888 previously already been compiled.
89892 . To run all tests in your project through Miri, use ` cargo miri test ` .
90903 . If you have a binary project, you can run it through Miri using ` cargo miri run ` .
9191
9292The first time you run Miri, it will perform some extra setup and install some
93- dependencies. It will ask you for confirmation before installing anything.
93+ dependencies. It will ask you for confirmation before installing anything.
9494
95- ` cargo miri run/test ` supports the exact same flags as ` cargo run/test ` . You
96- can pass arguments to Miri via ` MIRIFLAGS ` . For example,
95+ ` cargo miri run/test ` supports the exact same flags as ` cargo run/test ` . For
96+ example, ` cargo miri test filter ` only runs the tests containing ` filter ` in
97+ their name.
98+
99+ You can pass arguments to Miri via ` MIRIFLAGS ` . For example,
97100` MIRIFLAGS="-Zmiri-disable-stacked-borrows" cargo miri run ` runs the program
98101without checking the aliasing of references.
99102
100- When compiling code via ` cargo miri ` , the ` cfg(miri) ` config flag is set. You
103+ When compiling code via ` cargo miri ` , the ` cfg(miri) ` config flag is set. You
101104can use this to ignore test cases that fail under Miri because they do things
102105Miri does not support:
103106
104107``` rust
105108#[test]
106109#[cfg_attr(miri, ignore)]
107110fn does_not_work_on_miri () {
108- std :: thread :: spawn (|| println! (" Hello Thread!" ))
109- . join ()
110- . unwrap ();
111+ tokio :: run (futures :: future :: ok :: <_ , ()>(()));
111112}
112113```
113114
@@ -126,11 +127,11 @@ error: unsupported operation: can't call foreign function: bind
126127Miri can not only run a binary or test suite for your host target, it can also
127128perform cross-interpretation for arbitrary foreign targets: `cargo miri run
128129--target x86_64-unknown-linux-gnu` will run your program as if it was a Linux
129- program, no matter your host OS. This is particularly useful if you are using
130+ program, no matter your host OS. This is particularly useful if you are using
130131Windows, as the Linux target is much better supported than Windows targets.
131132
132133You can also use this to test platforms with different properties than your host
133- platform. For example ` cargo miri test --target mips64-unknown-linux-gnuabi64 `
134+ platform. For example ` cargo miri test --target mips64-unknown-linux-gnuabi64 `
134135will run your test suite on a big-endian target, which is useful for testing
135136endian-sensitive code.
136137
0 commit comments