Skip to content

Commit 21a707e

Browse files
committed
explain that the example is indeed UB, but that's okay
1 parent 94f7511 commit 21a707e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/test/mir-opt/validate_5.rs

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ fn main() {
2626
test(&mut 0);
2727

2828
let test_closure = unsafe { |x: &mut i32| write_42(x) };
29+
// Note that validation will fail if this is executed: The closure keeps the lock on
30+
// x, so the write in write_42 fails. This test just checks code generation,
31+
// so the UB doesn't matter.
2932
test_closure(&mut 0);
3033
}
3134

0 commit comments

Comments
 (0)