]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/regions/regions-fn-subtyping.rs
3 #![allow(unused_assignments)]
6 // pretty-expanded FIXME #23616
8 #![allow(unused_variables)]
10 // Should pass region checking.
11 fn ok(f
: Box
<dyn FnMut(&usize)>) {
12 // Here, g is a function that can accept a usize pointer with
13 // lifetime r, and f is a function that can accept a usize pointer
14 // with any lifetime. The assignment g = f should be OK (i.e.,
15 // f's type should be a subtype of g's type), because f can be
16 // used in any context that expects g's type. But this currently
18 let mut g
: Box
<dyn for<'r
> FnMut(&'r
usize)> = Box
::new(|x
| { }
);
22 // This version is the same as above, except that here, g's type is
24 fn ok_inferred(f
: Box
<dyn FnMut(&usize)>) {
25 let mut g
: Box
<dyn for<'r
> FnMut(&'r
usize)> = Box
::new(|_
| {}
);