@@ -83,31 +83,32 @@ determine a nightly version that comes with Miri and install that using
83
83
84
84
Now you can run your project in Miri:
85
85
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
87
87
dependencies to be compiled the right way, that would not happen if they have
88
88
previously already been compiled.
89
89
2 . To run all tests in your project through Miri, use ` cargo miri test ` .
90
90
3 . If you have a binary project, you can run it through Miri using ` cargo miri run ` .
91
91
92
92
The 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.
94
94
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,
97
100
` MIRIFLAGS="-Zmiri-disable-stacked-borrows" cargo miri run ` runs the program
98
101
without checking the aliasing of references.
99
102
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
101
104
can use this to ignore test cases that fail under Miri because they do things
102
105
Miri does not support:
103
106
104
107
``` rust
105
108
#[test]
106
109
#[cfg_attr(miri, ignore)]
107
110
fn does_not_work_on_miri () {
108
- std :: thread :: spawn (|| println! (" Hello Thread!" ))
109
- . join ()
110
- . unwrap ();
111
+ tokio :: run (futures :: future :: ok :: <_ , ()>(()));
111
112
}
112
113
```
113
114
@@ -126,11 +127,11 @@ error: unsupported operation: can't call foreign function: bind
126
127
Miri can not only run a binary or test suite for your host target, it can also
127
128
perform cross-interpretation for arbitrary foreign targets: `cargo miri run
128
129
--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
130
131
Windows, as the Linux target is much better supported than Windows targets.
131
132
132
133
You 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 `
134
135
will run your test suite on a big-endian target, which is useful for testing
135
136
endian-sensitive code.
136
137
0 commit comments