2018-08-30 14:18:55 +02:00
|
|
|
//@ run-pass
|
2018-09-25 23:51:35 +02:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
#![allow(unused_assignments)]
|
2012-05-21 13:04:30 -07:00
|
|
|
// Issue #2263.
|
|
|
|
|
|
2015-03-22 13:13:15 -07:00
|
|
|
|
2016-08-13 02:41:43 -07:00
|
|
|
#![allow(unused_variables)]
|
2015-02-15 09:52:21 +01:00
|
|
|
|
2012-05-21 13:04:30 -07:00
|
|
|
// Should pass region checking.
|
2019-05-28 14:47:21 -04:00
|
|
|
fn ok(f: Box<dyn FnMut(&usize)>) {
|
2015-03-25 17:06:52 -07:00
|
|
|
// Here, g is a function that can accept a usize pointer with
|
|
|
|
|
// lifetime r, and f is a function that can accept a usize pointer
|
2012-05-29 10:52:32 -07:00
|
|
|
// with any lifetime. The assignment g = f should be OK (i.e.,
|
|
|
|
|
// f's type should be a subtype of g's type), because f can be
|
|
|
|
|
// used in any context that expects g's type. But this currently
|
|
|
|
|
// fails.
|
2019-05-28 14:47:21 -04:00
|
|
|
let mut g: Box<dyn for<'r> FnMut(&'r usize)> = Box::new(|x| { });
|
2012-05-21 13:04:30 -07:00
|
|
|
g = f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This version is the same as above, except that here, g's type is
|
|
|
|
|
// inferred.
|
2019-05-28 14:47:21 -04:00
|
|
|
fn ok_inferred(f: Box<dyn FnMut(&usize)>) {
|
|
|
|
|
let mut g: Box<dyn for<'r> FnMut(&'r usize)> = Box::new(|_| {});
|
2012-05-21 13:04:30 -07:00
|
|
|
g = f;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2012-05-21 13:04:30 -07:00
|
|
|
}
|