2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2014-07-30 05:08:39 +00:00
|
|
|
// Ensures that single-word environments work right in unboxed closures.
|
|
|
|
// These take a different path in codegen.
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
fn a<F:Fn(isize, isize) -> isize>(f: F) -> isize {
|
2014-07-30 05:08:39 +00:00
|
|
|
f(1, 2)
|
|
|
|
}
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
fn b<F:FnMut(isize, isize) -> isize>(mut f: F) -> isize {
|
2014-07-30 05:08:39 +00:00
|
|
|
f(3, 4)
|
|
|
|
}
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
fn c<F:FnOnce(isize, isize) -> isize>(f: F) -> isize {
|
2014-07-30 05:08:39 +00:00
|
|
|
f(5, 6)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let z = 10;
|
2015-03-26 00:06:52 +00:00
|
|
|
assert_eq!(a(move |x: isize, y| x + y + z), 13);
|
|
|
|
assert_eq!(b(move |x: isize, y| x + y + z), 17);
|
|
|
|
assert_eq!(c(move |x: isize, y| x + y + z), 21);
|
2014-07-30 05:08:39 +00:00
|
|
|
}
|