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