Skip to content

Commit caeb554

Browse files
committed
do not inline black_box when building for Miri
1 parent e114d62 commit caeb554

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

library/core/src/hint.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ pub fn spin_loop() {
108108
/// Note however, that `black_box` is only (and can only be) provided on a "best-effort" basis. The
109109
/// extent to which it can block optimisations may vary depending upon the platform and code-gen
110110
/// backend used. Programs cannot rely on `black_box` for *correctness* in any way.
111-
#[inline]
111+
#[cfg_attr(not(miri), inline)]
112+
#[cfg_attr(miri, inline(never))]
112113
#[unstable(feature = "test", issue = "50297")]
113114
#[allow(unreachable_code)] // this makes #[cfg] a bit easier below.
114115
pub fn black_box<T>(dummy: T) -> T {

0 commit comments

Comments
 (0)