Skip to content

Commit

Permalink
make black_box a NOP in Miri
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Aug 8, 2020
1 parent e61621c commit 8385146
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion library/core/src/hint.rs
Expand Up @@ -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
}

0 comments on commit 8385146

Please sign in to comment.