From 8385146ffaddd90d79dff28d7924140ba079adfa Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 8 Aug 2020 10:36:16 +0200 Subject: [PATCH] make black_box a NOP in Miri --- library/core/src/hint.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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(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 }