]> git.lizzy.rs Git - rust.git/blob - src/test/ui/feature-gate-in_band_lifetimes.rs
Rollup merge of #53110 - Xanewok:save-analysis-remap-path, r=nrc
[rust.git] / src / test / ui / feature-gate-in_band_lifetimes.rs
1 // Copyright 2017 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 #![allow(warnings)]
12
13 // Make sure this related feature didn't accidentally enable this
14 #![feature(impl_header_lifetime_elision)]
15
16 fn foo(x: &'x u8) -> &'x u8 { x }
17 //~^ ERROR use of undeclared lifetime name
18 //~^^ ERROR use of undeclared lifetime name
19
20 struct X<'a>(&'a u8);
21
22 impl<'a> X<'a> {
23     fn inner(&self) -> &'a u8 {
24         self.0
25     }
26 }
27
28 impl<'a> X<'b> {
29 //~^ ERROR use of undeclared lifetime name
30     fn inner_2(&self) -> &'b u8 {
31     //~^ ERROR use of undeclared lifetime name
32         self.0
33     }
34 }
35
36 impl X<'b> {
37 //~^ ERROR use of undeclared lifetime name
38     fn inner_3(&self) -> &'b u8 {
39     //~^ ERROR use of undeclared lifetime name
40         self.0
41     }
42 }
43
44 struct Y<T>(T);
45
46 impl Y<&'a u8> {
47     //~^ ERROR use of undeclared lifetime name
48     fn inner(&self) -> &'a u8 {
49     //~^ ERROR use of undeclared lifetime name
50         self.0
51     }
52 }
53
54 trait MyTrait<'a> {
55     fn my_lifetime(&self) -> &'a u8;
56     fn any_lifetime() -> &'b u8;
57     //~^ ERROR use of undeclared lifetime name
58     fn borrowed_lifetime(&'b self) -> &'b u8;
59     //~^ ERROR use of undeclared lifetime name
60     //~^^ ERROR use of undeclared lifetime name
61 }
62
63 impl MyTrait<'a> for Y<&'a u8> {
64 //~^ ERROR use of undeclared lifetime name
65 //~^^ ERROR use of undeclared lifetime name
66     fn my_lifetime(&self) -> &'a u8 { self.0 }
67     //~^ ERROR use of undeclared lifetime name
68     fn any_lifetime() -> &'b u8 { &0 }
69     //~^ ERROR use of undeclared lifetime name
70     fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 }
71     //~^ ERROR use of undeclared lifetime name
72     //~^^ ERROR use of undeclared lifetime name
73 }
74
75 fn main() {}