]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/associated-types/bound-lifetime-constrained.rs
Unignore u128 test for stage 0,1
[rust.git] / src / test / compile-fail / associated-types / bound-lifetime-constrained.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: func object clause
12
13 #![allow(dead_code)]
14 #![feature(rustc_attrs)]
15 #![deny(hr_lifetime_in_assoc_type)]
16
17 trait Foo<'a> {
18     type Item;
19 }
20
21 impl<'a> Foo<'a> for() {
22     type Item = ();
23 }
24
25 // Check that appearing in a projection input in the argument is not enough:
26 #[cfg(func)]
27 fn func1(_: for<'a> fn(<() as Foo<'a>>::Item) -> &'a i32) {
28     //[func]~^ ERROR return type references lifetime `'a`
29     //[func]~| WARNING previously accepted
30 }
31
32 // Check that appearing in a projection input in the return still
33 // causes an error:
34 #[cfg(func)]
35 fn func2(_: for<'a> fn() -> <() as Foo<'a>>::Item) {
36     //[func]~^ ERROR return type references lifetime `'a`
37     //[func]~| WARNING previously accepted
38 }
39
40 #[cfg(object)]
41 fn object1(_: Box<for<'a> Fn(<() as Foo<'a>>::Item) -> &'a i32>) {
42     //[object]~^ ERROR `Output` references lifetime `'a`
43     //[object]~| WARNING previously accepted
44 }
45
46 #[cfg(object)]
47 fn object2(_: Box<for<'a> Fn() -> <() as Foo<'a>>::Item>) {
48     //[object]~^ ERROR `Output` references lifetime `'a`
49     //[object]~| WARNING previously accepted
50 }
51
52 #[cfg(clause)]
53 fn clause1<T>() where T: for<'a> Fn(<() as Foo<'a>>::Item) -> &'a i32 {
54     //[clause]~^ ERROR `Output` references lifetime `'a`
55     //[clause]~| WARNING previously accepted
56 }
57
58 #[cfg(clause)]
59 fn clause2<T>() where T: for<'a> Fn() -> <() as Foo<'a>>::Item {
60     //[clause]~^ ERROR `Output` references lifetime `'a`
61     //[clause]~| WARNING previously accepted
62 }
63
64 #[rustc_error]
65 fn main() { } //[ok]~ ERROR compilation successful