]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/associated-types/bound-lifetime-in-return-only.rs
Rollup merge of #39604 - est31:i128_tests, r=alexcrichton
[rust.git] / src / test / compile-fail / associated-types / bound-lifetime-in-return-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: sig local structure 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(sig)]
23 fn sig1(_: for<'a> fn() -> &'a i32) {
24     //[sig]~^ ERROR return type references lifetime `'a`
25 }
26
27 #[cfg(sig)]
28 fn sig2(_: for<'a, 'b> fn(&'b i32) -> &'a i32) {
29     //[sig]~^ ERROR return type references lifetime `'a`
30 }
31
32 #[cfg(local)]
33 fn local1() {
34     let _: for<'a> fn() -> &'a i32 = loop { };
35     //[local]~^ ERROR return type references lifetime `'a`
36 }
37
38 #[cfg(structure)]
39 struct Struct1 {
40     x: for<'a> fn() -> &'a i32
41     //[structure]~^ ERROR return type references lifetime `'a`
42 }
43
44 #[cfg(elision)]
45 fn elision(_: fn() -> &i32) {
46     //[elision]~^ ERROR E0106
47 }
48
49 struct Parameterized<'a> { x: &'a str }
50
51 #[cfg(ok)]
52 fn ok1(_: &for<'a> Fn(&Parameterized<'a>) -> &'a i32) {
53 }
54
55 #[cfg(ok)]
56 fn ok2(_: &for<'a,'b> Fn<(&'b Parameterized<'a>,), Output=&'a i32>) {
57 }
58
59 #[rustc_error]
60 fn main() { } //[ok]~ ERROR compilation successful