1 fn with_closure_expecting_fn_with_free_region<F>(_: F)
2 where F: for<'a> FnOnce(fn(&'a u32), &i32)
6 fn with_closure_expecting_fn_with_bound_region<F>(_: F)
7 where F: FnOnce(fn(&u32), &i32)
11 fn expect_free_supply_free_from_fn<'x>(x: &'x u32) {
12 // Here, the type given for `'x` "obscures" a region from the
13 // expected signature that is bound at closure level.
14 with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
15 //~^ ERROR mismatched types
16 //~| ERROR mismatched types
19 fn expect_free_supply_free_from_closure() {
20 // A variant on the previous test. Here, the region `'a` will be
21 // bound at the closure level, just as is expected, so no error
23 type Foo<'a> = fn(&'a u32);
24 with_closure_expecting_fn_with_free_region(|_x: Foo<'_>, y| {});
27 fn expect_free_supply_bound() {
28 // Here, we are given a function whose region is bound at closure level,
29 // but we expect one bound in the argument. Error results.
30 with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {});
31 //~^ ERROR type mismatch
34 fn expect_bound_supply_free_from_fn<'x>(x: &'x u32) {
35 // Here, we are given a `fn(&u32)` but we expect a `fn(&'x
36 // u32)`. In principle, this could be ok, but we demand equality.
37 with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {});
38 //~^ ERROR type mismatch
41 fn expect_bound_supply_free_from_closure() {
42 // A variant on the previous test. Here, the region `'a` will be
43 // bound at the closure level, but we expect something bound at
44 // the argument level.
45 type Foo<'a> = fn(&'a u32);
46 with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| {
47 //~^ ERROR type mismatch
51 fn expect_bound_supply_bound<'x>(x: &'x u32) {
52 // No error in this case. The supplied type supplies the bound
53 // regions, and hence we are able to figure out the type of `y`
54 // from the expected type
55 with_closure_expecting_fn_with_bound_region(|x: for<'z> fn(&'z u32), y| {