]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/associated-types/bound-lifetime-in-binding-only.rs
Unignore u128 test for stage 0,1
[rust.git] / src / test / compile-fail / associated-types / bound-lifetime-in-binding-only.rs
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)]
16 #![deny(hr_lifetime_in_assoc_type)]
17
18 trait Foo {
19     type Item;
20 }
21
22 #[cfg(angle)]
23 fn angle<T: for<'a> Foo<Item=&'a i32>>() {
24     //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a`
25     //[angle]~| WARNING previously accepted
26 }
27
28 #[cfg(angle)]
29 fn angle1<T>() where T: for<'a> Foo<Item=&'a i32> {
30     //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a`
31     //[angle]~| WARNING previously accepted
32 }
33
34 #[cfg(angle)]
35 fn angle2<T>() where for<'a> T: Foo<Item=&'a i32> {
36     //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a`
37     //[angle]~| WARNING previously accepted
38 }
39
40 #[cfg(angle)]
41 fn angle3(_: &for<'a> Foo<Item=&'a i32>) {
42     //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a`
43     //[angle]~| WARNING previously accepted
44 }
45
46 #[cfg(paren)]
47 fn paren<T: for<'a> Fn() -> &'a i32>() {
48     //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a`
49     //[paren]~| WARNING previously accepted
50 }
51
52 #[cfg(paren)]
53 fn paren1<T>() where T: for<'a> Fn() -> &'a i32 {
54     //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a`
55     //[paren]~| WARNING previously accepted
56 }
57
58 #[cfg(paren)]
59 fn paren2<T>() where for<'a> T: Fn() -> &'a i32 {
60     //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a`
61     //[paren]~| WARNING previously accepted
62 }
63
64 #[cfg(paren)]
65 fn paren3(_: &for<'a> Fn() -> &'a i32) {
66     //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a`
67     //[paren]~| WARNING previously accepted
68 }
69
70 #[cfg(elision)]
71 fn elision<T: Fn() -> &i32>() {
72     //[elision]~^ ERROR E0106
73 }
74
75 struct Parameterized<'a> { x: &'a str }
76
77 #[cfg(ok)]
78 fn ok1<T: for<'a> Fn(&Parameterized<'a>) -> &'a i32>() {
79 }
80
81 #[cfg(ok)]
82 fn ok2<T: for<'a,'b> Fn<(&'b Parameterized<'a>,), Output=&'a i32>>() {
83 }
84
85 #[cfg(ok)]
86 fn ok3<T>() where for<'a> Parameterized<'a>: Foo<Item=&'a i32> {
87 }
88
89 #[rustc_error]
90 fn main() { } //[ok]~ ERROR compilation successful