Skip to content

Commit cfa76c4

Browse files
committed
black_box should inhibit optimizations on platforms without inline assembly
1 parent f244383 commit cfa76c4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/libcore/hint.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ pub fn black_box<T>(dummy: T) -> T {
106106
dummy
107107
}
108108
#[cfg(any(target_arch = "asmjs", target_arch = "wasm32"))] {
109-
#[inline(never)] fn black_box_(x: T) -> T { x }
110-
black_box_(dummy)
111-
}
109+
unsafe {
110+
let ret = crate::ptr::read_volatile(&dummy);
111+
crate::mem::forget(dummy);
112+
ret
113+
}
114+
}
112115
}

0 commit comments

Comments
 (0)