]> git.proxmox.com Git - rustc.git/blame - src/test/ui/associated-types/bound-lifetime-in-binding-only.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / test / ui / associated-types / bound-lifetime-in-binding-only.rs
CommitLineData
a7813a04
XL
1// revisions: angle paren 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(angle)]
12fn angle<T: for<'a> Foo<Item=&'a i32>>() {
13 //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a`
a7813a04
XL
14}
15
16#[cfg(angle)]
17fn angle1<T>() where T: for<'a> Foo<Item=&'a i32> {
18 //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a`
a7813a04
XL
19}
20
21#[cfg(angle)]
22fn angle2<T>() where for<'a> T: Foo<Item=&'a i32> {
23 //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a`
a7813a04
XL
24}
25
26#[cfg(angle)]
dc9dc135 27fn angle3(_: &dyn for<'a> Foo<Item=&'a i32>) {
a7813a04 28 //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a`
a7813a04
XL
29}
30
31#[cfg(paren)]
32fn paren<T: for<'a> Fn() -> &'a i32>() {
33 //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a`
a7813a04
XL
34}
35
36#[cfg(paren)]
37fn paren1<T>() where T: for<'a> Fn() -> &'a i32 {
38 //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a`
a7813a04
XL
39}
40
41#[cfg(paren)]
42fn paren2<T>() where for<'a> T: Fn() -> &'a i32 {
43 //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a`
a7813a04
XL
44}
45
46#[cfg(paren)]
dc9dc135 47fn paren3(_: &dyn for<'a> Fn() -> &'a i32) {
a7813a04 48 //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a`
a7813a04
XL
49}
50
51#[cfg(elision)]
52fn elision<T: Fn() -> &i32>() {
53 //[elision]~^ ERROR E0106
54}
55
56struct Parameterized<'a> { x: &'a str }
57
58#[cfg(ok)]
59fn ok1<T: for<'a> Fn(&Parameterized<'a>) -> &'a i32>() {
60}
61
62#[cfg(ok)]
63fn ok2<T: for<'a,'b> Fn<(&'b Parameterized<'a>,), Output=&'a i32>>() {
64}
65
66#[cfg(ok)]
67fn ok3<T>() where for<'a> Parameterized<'a>: Foo<Item=&'a i32> {
68}
69
70#[rustc_error]
60c5eb7d 71fn main() { } //[ok]~ ERROR fatal error triggered by #[rustc_error]