1 fn with_closure_expecting_fn_with_free_region<F>(_: F)
3 F: for<'a> FnOnce(fn(&'a u32), &i32),
7 fn with_closure_expecting_fn_with_bound_region<F>(_: F)
9 F: FnOnce(fn(&u32), &i32),
13 fn expect_free_supply_free_from_fn<'x>(x: &'x u32) {
14 // Here, the type given for `'x` "obscures" a region from the
15 // expected signature that is bound at closure level.
16 with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
17 //~^ ERROR lifetime may not live long enough
18 //~| ERROR lifetime may not live long enough
21 fn expect_free_supply_free_from_closure() {
22 // A variant on the previous test. Here, the region `'a` will be
23 // bound at the closure level, just as is expected, so no error
25 type Foo<'a> = fn(&'a u32);
26 with_closure_expecting_fn_with_free_region(|_x: Foo<'_>, y| {});
29 fn expect_free_supply_bound() {
30 // Here, we are given a function whose region is bound at closure level,
31 // but we expect one bound in the argument. Error results.
32 with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {});
33 //~^ ERROR mismatched types
36 fn expect_bound_supply_free_from_fn<'x>(x: &'x u32) {
37 // Here, we are given a `fn(&u32)` but we expect a `fn(&'x
38 // u32)`. In principle, this could be ok, but we demand equality.
39 with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {});
40 //~^ ERROR mismatched types
43 fn expect_bound_supply_free_from_closure() {
44 // A variant on the previous test. Here, the region `'a` will be
45 // bound at the closure level, but we expect something bound at
46 // the argument level.
47 type Foo<'a> = fn(&'a u32);
48 with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| {
49 //~^ ERROR mismatched types
53 fn expect_bound_supply_bound<'x>(x: &'x u32) {
54 // No error in this case. The supplied type supplies the bound
55 // regions, and hence we are able to figure out the type of `y`
56 // from the expected type
57 with_closure_expecting_fn_with_bound_region(|x: for<'z> fn(&'z u32), y| {});