Skip to content

Commit b442120

Browse files
committed
add tests from crater for liveness causing scope differences
1 parent 60d4eb2 commit b442120

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// This is a non-regression test about differences in scopes computed by NLLs and `-Zpolonius=next`
2+
// found during the crater run for PR #117593.
3+
//
4+
// Live loans were computed too early compared to some of the liveness data coming from later passes
5+
// than `liveness::trace`, on some specific CFGs shapes: a variable was dead during tracing but its
6+
// regions were marked live later, and live loans were not recomputed at this point.
7+
8+
// check-pass
9+
// revisions: nll polonius
10+
// [polonius] compile-flags: -Zpolonius=next
11+
12+
// minimized from wavefc-cli-3.0.0
13+
fn repro1() {
14+
let a = 0;
15+
let closure = || {
16+
let _b = a;
17+
};
18+
19+
let callback = if true { Some(closure) } else { None };
20+
do_it(callback);
21+
}
22+
fn do_it<F>(_: Option<F>)
23+
where
24+
F: Fn(),
25+
{
26+
}
27+
28+
// minimized from simple-server-0.4.0
29+
fn repro2() {
30+
let mut a = &();
31+
let s = S(&mut a);
32+
let _ = if true { Some(s) } else { None };
33+
}
34+
struct S<'a>(&'a mut &'a ());
35+
36+
// minimized from https://github.com/SHaaD94/AICup2022
37+
fn repro3() {
38+
let runner = ();
39+
let writer = debug_interface(&runner);
40+
let _ = if true { Some(writer) } else { None };
41+
}
42+
fn debug_interface(_: &()) -> &mut dyn std::io::Write {
43+
unimplemented!()
44+
}
45+
46+
fn main() {}

0 commit comments

Comments
 (0)