Skip to content

Commit adba97e

Browse files
committed
document the cargo-miri feature
1 parent d67da9f commit adba97e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ example above), overriding it in your project directory as well, or use `rustup
3939
default nightly` (or `rustup default nightly-YYYY-MM-DD`) to globally make
4040
`nightly` the default toolchain.
4141

42-
Now you can run your project in miri:
42+
Now you can run your project in Miri:
4343

4444
1. Run `cargo clean` to eliminate any cached dependencies. Miri needs your
4545
dependencies to be compiled the right way, that would not happen if they have
@@ -48,6 +48,19 @@ Now you can run your project in miri:
4848
3. If you have a binary project, you can run it through Miri using `cargo
4949
+nightly miri run`.
5050

51+
When running code via `cargo miri`, the `cargo-miri` feature is set. You can
52+
use this to exclude test cases that will fail under Miri because they do things
53+
Miri does not support:
54+
55+
```rust
56+
#[cfg(not(feature = "cargo-miri"))]
57+
#[test]
58+
fn does_not_work_on_miri() {
59+
let x = 0u8;
60+
assert!(&x as *const _ as usize % 4 < 4);
61+
}
62+
```
63+
5164
### Common Problems
5265

5366
When using the above instructions, you may encounter a number of confusing compiler

0 commit comments

Comments
 (0)