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