9
9
// except according to those terms.
10
10
11
11
// ignore-tidy-linelength
12
- // compile-flags: -Z verbose -Z mir-emit-validate=2
12
+ // compile-flags: -Z verbose -Z mir-emit-validate=2 -Z span_free_formats
13
13
14
- // Make sure unsafe fns and fns with an unsafe block only get full validation.
14
+ // Make sure unsafe fns and fns with an unsafe block still get full validation.
15
15
16
16
unsafe fn write_42 ( x : * mut i32 ) -> bool {
17
17
* x = 42 ;
@@ -26,12 +26,12 @@ fn main() {
26
26
test ( & mut 0 ) ;
27
27
28
28
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.
29
32
test_closure ( & mut 0 ) ;
30
33
}
31
34
32
- // FIXME: Also test code generated inside the closure, make sure it has validation. Unfortunately,
33
- // the interesting lines of code also contain name of the source file, so we cannot test for it.
34
-
35
35
// END RUST SOURCE
36
36
// START rustc.node17.EraseRegions.after.mir
37
37
// fn test(_1: &ReErased mut i32) -> () {
@@ -42,3 +42,22 @@ fn main() {
42
42
// }
43
43
// }
44
44
// END rustc.node17.EraseRegions.after.mir
45
+ // START rustc.node46.EraseRegions.after.mir
46
+ // fn main::{{closure}}(_1: &ReErased [closure@NodeId(46)], _2: &ReErased mut i32) -> bool {
47
+ // bb0: {
48
+ // Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483660) => validate_5/8cd878b::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(46)], _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483660) => validate_5/8cd878b::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]);
49
+ // StorageLive(_3);
50
+ // _3 = _2;
51
+ // StorageLive(_4);
52
+ // StorageLive(_5);
53
+ // Validate(Suspend(ReScope(Misc(NodeId(44)))), [(*_3): i32]);
54
+ // _5 = &ReErased mut (*_3);
55
+ // Validate(Acquire, [(*_5): i32/ReScope(Misc(NodeId(44)))]);
56
+ // _4 = _5 as *mut i32 (Misc);
57
+ // StorageDead(_5);
58
+ // EndRegion(ReScope(Misc(NodeId(44))));
59
+ // Validate(Release, [_0: bool, _4: *mut i32]);
60
+ // _0 = const write_42(_4) -> bb1;
61
+ // }
62
+ // }
63
+ // END rustc.node46.EraseRegions.after.mir
0 commit comments