]> git.proxmox.com Git - rustc.git/blob - src/test/ui/polymorphization/closure_in_upvar/fnmut.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / polymorphization / closure_in_upvar / fnmut.rs
1 // build-pass
2 // compile-flags:-Zpolymorphize=on -Csymbol-mangling-version=v0
3
4 fn foo(f: impl Fn()) {
5 // Mutate an upvar from `x` so that it implements `FnMut`.
6 let mut outer = 3;
7 let mut x = |_: ()| {
8 outer = 4;
9 ()
10 };
11
12 // Don't use `f` in `y`, but refer to `x` so that the closure substs contain a reference to
13 // `x` that will differ for each instantiation despite polymorphisation of the varying
14 // argument.
15 let mut y = || x(());
16
17 // Consider `f` used in `foo`.
18 f();
19 // Use `y` so that it is visited in monomorphisation collection.
20 y();
21 }
22
23 fn entry_a() {
24 foo(|| ());
25 }
26
27 fn entry_b() {
28 foo(|| ());
29 }
30
31 fn main() {
32 entry_a();
33 entry_b();
34 }