]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / lifetime-elision-return-type-requires-explicit-lifetime.rs
CommitLineData
1a4d82fc
JJ
1// Copyright 2014 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// Lifetime annotation needed because we have no arguments.
12fn f() -> &isize { //~ ERROR missing lifetime specifier
13//~^ HELP there is no value for it to be borrowed from
54a0048b
SL
14//~| HELP run `rustc --explain E0106` to see a detailed explanation
15//~| HELP consider giving it a 'static lifetime
1a4d82fc
JJ
16 panic!()
17}
18
19// Lifetime annotation needed because we have two by-reference parameters.
20fn g(_x: &isize, _y: &isize) -> &isize { //~ ERROR missing lifetime specifier
21//~^ HELP the signature does not say whether it is borrowed from `_x` or `_y`
54a0048b 22//~| HELP run `rustc --explain E0106` to see a detailed explanation
1a4d82fc
JJ
23 panic!()
24}
25
26struct Foo<'a> {
27 x: &'a isize,
28}
29
30// Lifetime annotation needed because we have two lifetimes: one as a parameter
31// and one on the reference.
32fn h(_x: &Foo) -> &isize { //~ ERROR missing lifetime specifier
33//~^ HELP the signature does not say which one of `_x`'s 2 elided lifetimes it is borrowed from
54a0048b 34//~| HELP run `rustc --explain E0106` to see a detailed explanation
1a4d82fc
JJ
35 panic!()
36}
37
38fn i(_x: isize) -> &isize { //~ ERROR missing lifetime specifier
39//~^ HELP this function's return type contains a borrowed value
54a0048b
SL
40//~| HELP run `rustc --explain E0106` to see a detailed explanation
41//~| HELP consider giving it an explicit bounded or 'static lifetime
1a4d82fc
JJ
42 panic!()
43}
44
45fn main() {}