]> git.lizzy.rs Git - rust.git/blob - src/test/ui/unboxed-closures/unboxed-closures-single-word-env.rs
Auto merge of #103600 - compiler-errors:early-binder-nits, r=spastorino
[rust.git] / src / test / ui / unboxed-closures / unboxed-closures-single-word-env.rs
1 // run-pass
2 // Ensures that single-word environments work right in unboxed closures.
3 // These take a different path in codegen.
4
5 fn a<F:Fn(isize, isize) -> isize>(f: F) -> isize {
6     f(1, 2)
7 }
8
9 fn b<F:FnMut(isize, isize) -> isize>(mut f: F) -> isize {
10     f(3, 4)
11 }
12
13 fn c<F:FnOnce(isize, isize) -> isize>(f: F) -> isize {
14     f(5, 6)
15 }
16
17 fn main() {
18     let z = 10;
19     assert_eq!(a(move |x: isize, y| x + y + z), 13);
20     assert_eq!(b(move |x: isize, y| x + y + z), 17);
21     assert_eq!(c(move |x: isize, y| x + y + z), 21);
22 }