1 // aux-build:lifetime_bound_will_change_warning_lib.rs
3 // Test that various corner cases cause an error. These are tests
4 // that used to pass before we tweaked object defaults.
7 #![allow(unused_variables)]
10 extern crate lifetime_bound_will_change_warning_lib as lib;
12 fn just_ref(x: &dyn Fn()) {
15 fn ref_obj(x: &Box<dyn Fn()>) {
16 // this will change to &Box<Fn()+'static>...
18 // Note: no warning is issued here, because the type of `x` will change to 'static
19 if false { ref_obj(x); }
22 fn test1<'a>(x: &'a Box<dyn Fn() + 'a>) {
23 // just_ref will stay the same.
27 fn test1cc<'a>(x: &'a Box<dyn Fn() + 'a>) {
28 // same as test1, but cross-crate
32 fn test2<'a>(x: &'a Box<dyn Fn() + 'a>) {
33 // but ref_obj will not, so warn.
34 ref_obj(x) //~ ERROR mismatched types
37 fn test2cc<'a>(x: &'a Box<dyn Fn() + 'a>) {
38 // same as test2, but cross crate
39 lib::ref_obj(x) //~ ERROR mismatched types
42 fn test3<'a>(x: &'a Box<dyn Fn() + 'static>) {
43 // here, we have a 'static bound, so even when ref_obj changes, no error results
47 fn test3cc<'a>(x: &'a Box<dyn Fn() + 'static>) {
48 // same as test3, but cross crate