]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-types/bound-lifetime-in-return-only.rs
Merge commit '7b73b60faca71d01d900e49831fcb84553e93019' into sync-rustfmt
[rust.git] / src / test / ui / associated-types / bound-lifetime-in-return-only.rs
1 // revisions: sig local structure ok elision
2
3 #![allow(dead_code)]
4 #![feature(rustc_attrs)]
5 #![feature(unboxed_closures)]
6
7 trait Foo {
8     type Item;
9 }
10
11 #[cfg(sig)]
12 fn sig1(_: for<'a> fn() -> &'a i32) {
13     //[sig]~^ ERROR return type references lifetime `'a`
14 }
15
16 #[cfg(sig)]
17 fn sig2(_: for<'a, 'b> fn(&'b i32) -> &'a i32) {
18     //[sig]~^ ERROR return type references lifetime `'a`
19 }
20
21 #[cfg(local)]
22 fn local1() {
23     let _: for<'a> fn() -> &'a i32 = loop { };
24     //[local]~^ ERROR return type references lifetime `'a`
25 }
26
27 #[cfg(structure)]
28 struct Struct1 {
29     x: for<'a> fn() -> &'a i32
30     //[structure]~^ ERROR return type references lifetime `'a`
31 }
32
33 #[cfg(elision)]
34 fn elision(_: fn() -> &i32) {
35     //[elision]~^ ERROR E0106
36 }
37
38 struct Parameterized<'a> { x: &'a str }
39
40 #[cfg(ok)]
41 fn ok1(_: &dyn for<'a> Fn(&Parameterized<'a>) -> &'a i32) {
42 }
43
44 #[cfg(ok)]
45 fn ok2(_: &dyn for<'a,'b> Fn<(&'b Parameterized<'a>,), Output=&'a i32>) {
46 }
47
48 #[rustc_error]
49 fn main() { } //[ok]~ ERROR fatal error triggered by #[rustc_error]