summaryrefslogtreecommitdiffstats
path: root/src/test/ui/associated-types/bound-lifetime-in-binding-only.rs
blob: e714457ef7b382ecd7d7abe819927cd6851c94ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// revisions: angle paren ok elision

#![allow(dead_code)]
#![feature(rustc_attrs)]
#![feature(unboxed_closures)]

trait Foo {
    type Item;
}

#[cfg(angle)]
fn angle<T: for<'a> Foo<Item=&'a i32>>() {
    //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a`
}

#[cfg(angle)]
fn angle1<T>() where T: for<'a> Foo<Item=&'a i32> {
    //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a`
}

#[cfg(angle)]
fn angle2<T>() where for<'a> T: Foo<Item=&'a i32> {
    //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a`
}

#[cfg(angle)]
fn angle3(_: &dyn for<'a> Foo<Item=&'a i32>) {
    //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a`
}

#[cfg(paren)]
fn paren<T: for<'a> Fn() -> &'a i32>() {
    //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a`
}

#[cfg(paren)]
fn paren1<T>() where T: for<'a> Fn() -> &'a i32 {
    //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a`
}

#[cfg(paren)]
fn paren2<T>() where for<'a> T: Fn() -> &'a i32 {
    //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a`
}

#[cfg(paren)]
fn paren3(_: &dyn for<'a> Fn() -> &'a i32) {
    //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a`
}

#[cfg(elision)]
fn elision<T: Fn() -> &i32>() {
    //[elision]~^ ERROR E0106
}

struct Parameterized<'a> { x: &'a str }

#[cfg(ok)]
fn ok1<T: for<'a> Fn(&Parameterized<'a>) -> &'a i32>() {
}

#[cfg(ok)]
fn ok2<T: for<'a,'b> Fn<(&'b Parameterized<'a>,), Output=&'a i32>>() {
}

#[cfg(ok)]
fn ok3<T>() where for<'a> Parameterized<'a>: Foo<Item=&'a i32> {
}

#[rustc_error]
fn main() { } //[ok]~ ERROR fatal error triggered by #[rustc_error]