diff options
| author | Ralf Jung <post@ralfj.de> | 2020-08-08 10:36:16 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2020-08-08 10:50:30 +0200 |
| commit | 8385146ffaddd90d79dff28d7924140ba079adfa (patch) | |
| tree | 444bce4b6c0a72ed632c693313c10b50b7f38e2a | |
| parent | e61621c3078f25365d58cb508cda745007e64d85 (diff) | |
| download | rust-8385146ffaddd90d79dff28d7924140ba079adfa.tar.gz rust-8385146ffaddd90d79dff28d7924140ba079adfa.zip | |
make black_box a NOP in Miri
| -rw-r--r-- | library/core/src/hint.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/library/core/src/hint.rs b/library/core/src/hint.rs index 3116815f5d6..3dc0ee2b555 100644 --- a/library/core/src/hint.rs +++ b/library/core/src/hint.rs @@ -119,9 +119,11 @@ pub fn black_box<T>(dummy: T) -> T { // box. This isn't the greatest implementation since it probably deoptimizes // more than we want, but it's so far good enough. + #[cfg(not(miri))] // This is just a hint, so it is fine to skip in Miri. // SAFETY: the inline assembly is a no-op. unsafe { llvm_asm!("" : : "r"(&dummy)); - dummy } + + dummy } |
