1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // aux-build:lifetime_bound_will_change_warning_lib.rs
13 // Test that various corner cases cause an error. These are tests
14 // that used to pass before we tweaked object defaults.
17 #![allow(unused_variables)]
18 #![feature(rustc_attrs)]
20 extern crate lifetime_bound_will_change_warning_lib
as lib
;
22 fn just_ref(x
: &Fn()) {
25 fn ref_obj(x
: &Box
<Fn()>) {
26 // this will change to &Box<Fn()+'static>...
28 // Note: no warning is issued here, because the type of `x` will change to 'static
29 if false { ref_obj(x); }
32 fn test1
<'a
>(x
: &'a Box
<Fn()+'a
>) {
33 // just_ref will stay the same.
37 fn test1cc
<'a
>(x
: &'a Box
<Fn()+'a
>) {
38 // same as test1, but cross-crate
42 fn test2
<'a
>(x
: &'a Box
<Fn()+'a
>) {
43 // but ref_obj will not, so warn.
44 ref_obj(x
) //~ ERROR mismatched types
47 fn test2cc
<'a
>(x
: &'a Box
<Fn()+'a
>) {
48 // same as test2, but cross crate
49 lib
::ref_obj(x
) //~ ERROR mismatched types
52 fn test3
<'a
>(x
: &'a Box
<Fn()+'
static>) {
53 // here, we have a 'static bound, so even when ref_obj changes, no error results
57 fn test3cc
<'a
>(x
: &'a Box
<Fn()+'
static>) {
58 // same as test3, but cross crate