Skip to content

Commit 8385146

Browse files
committedAug 8, 2020
make black_box a NOP in Miri
1 parent e61621c commit 8385146

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed
 

‎library/core/src/hint.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,11 @@ pub fn black_box<T>(dummy: T) -> T {
119119
// box. This isn't the greatest implementation since it probably deoptimizes
120120
// more than we want, but it's so far good enough.
121121

122+
#[cfg(not(miri))] // This is just a hint, so it is fine to skip in Miri.
122123
// SAFETY: the inline assembly is a no-op.
123124
unsafe {
124125
llvm_asm!("" : : "r"(&dummy));
125-
dummy
126126
}
127+
128+
dummy
127129
}

0 commit comments

Comments
 (0)
Please sign in to comment.