]> git.proxmox.com Git - rustc.git/blob - src/test/ui/regions/regions-fn-subtyping.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / regions / regions-fn-subtyping.rs
1 // run-pass
2 #![allow(dead_code)]
3 #![allow(unused_assignments)]
4 // Issue #2263.
5
6 // pretty-expanded FIXME #23616
7
8 #![allow(unused_variables)]
9
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
17 // fails.
18 let mut g: Box<dyn for<'r> FnMut(&'r usize)> = Box::new(|x| { });
19 g = f;
20 }
21
22 // This version is the same as above, except that here, g's type is
23 // inferred.
24 fn ok_inferred(f: Box<dyn FnMut(&usize)>) {
25 let mut g: Box<dyn for<'r> FnMut(&'r usize)> = Box::new(|_| {});
26 g = f;
27 }
28
29 pub fn main() {
30 }