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.
35 //~^ ERROR borrowed data escapes
38 fn test2cc
<'a
>(x
: &'a Box
<dyn Fn() + 'a
>) {
39 // same as test2, but cross crate
41 //~^ ERROR borrowed data escapes
44 fn test3
<'a
>(x
: &'a Box
<dyn Fn() + '
static>) {
45 // here, we have a 'static bound, so even when ref_obj changes, no error results
49 fn test3cc
<'a
>(x
: &'a Box
<dyn Fn() + '
static>) {
50 // same as test3, but cross crate