Skip to content

Commit 125326e

Browse files
committed
Add test case for the need for fake_read callbacks
1 parent d4c3643 commit 125326e

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// run-pass
2+
// compile-flags: -Zdrop-tracking
3+
4+
// Based on addassign-yield.rs, but with drop tracking enabled. Originally we did not implement
5+
// the fake_read callback on ExprUseVisitor which caused this case to break.
6+
7+
#![feature(generators)]
8+
9+
fn foo() {
10+
let _y = static || {
11+
let x = &mut 0;
12+
*{
13+
yield;
14+
x
15+
} += match String::new() {
16+
_ => 0,
17+
};
18+
};
19+
20+
// Please don't ever actually write something like this
21+
let _z = static || {
22+
let x = &mut 0;
23+
*{
24+
let inner = &mut 1;
25+
*{
26+
yield ();
27+
inner
28+
} += match String::new() {
29+
_ => 1,
30+
};
31+
yield;
32+
x
33+
} += match String::new() {
34+
_ => 2,
35+
};
36+
};
37+
}
38+
39+
fn main() {
40+
foo()
41+
}

0 commit comments

Comments
 (0)