]> git.proxmox.com Git - rustc.git/blob - src/test/ui/rust-2018/edition-lint-infer-outlives.fixed
New upstream version 1.31.0~beta.4+dfsg1
[rustc.git] / src / test / ui / rust-2018 / edition-lint-infer-outlives.fixed
1 // Copyright 2018 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 // run-rustfix
12
13 #![allow(unused)]
14 #![deny(explicit_outlives_requirements)]
15
16 use std::fmt::{Debug, Display};
17
18
19 // Programmatically generated examples!
20 //
21 // Exercise outlives bounds for each of the following parameter/position
22 // combinations—
23 //
24 // • one generic parameter (T) bound inline
25 // • one parameter (T) with a where clause
26 // • two parameters (T and U), both bound inline
27 // • two parameters (T and U), one bound inline, one with a where clause
28 // • two parameters (T and U), both with where clauses
29 //
30 // —and for every permutation of 0, 1, or 2 lifetimes to outlive and 0 or 1
31 // trait bounds distributed among said parameters (subject to no where clause
32 // being empty and the struct having at least one lifetime).
33
34
35 struct TeeOutlivesAy<'a, T> {
36 //~^ ERROR outlives requirements can be inferred
37 tee: &'a T
38 }
39
40 struct TeeOutlivesAyIsDebug<'a, T: Debug> {
41 //~^ ERROR outlives requirements can be inferred
42 tee: &'a T
43 }
44
45 struct TeeIsDebugOutlivesAy<'a, T: Debug> {
46 //~^ ERROR outlives requirements can be inferred
47 tee: &'a T
48 }
49
50 struct TeeOutlivesAyBee<'a, 'b, T> {
51 //~^ ERROR outlives requirements can be inferred
52 tee: &'a &'b T
53 }
54
55 struct TeeOutlivesAyBeeIsDebug<'a, 'b, T: Debug> {
56 //~^ ERROR outlives requirements can be inferred
57 tee: &'a &'b T
58 }
59
60 struct TeeIsDebugOutlivesAyBee<'a, 'b, T: Debug> {
61 //~^ ERROR outlives requirements can be inferred
62 tee: &'a &'b T
63 }
64
65 struct TeeWhereOutlivesAy<'a, T> {
66 //~^ ERROR outlives requirements can be inferred
67 tee: &'a T
68 }
69
70 struct TeeWhereOutlivesAyIsDebug<'a, T> where T: Debug {
71 //~^ ERROR outlives requirements can be inferred
72 tee: &'a T
73 }
74
75 struct TeeWhereIsDebugOutlivesAy<'a, T> where T: Debug {
76 //~^ ERROR outlives requirements can be inferred
77 tee: &'a T
78 }
79
80 struct TeeWhereOutlivesAyBee<'a, 'b, T> {
81 //~^ ERROR outlives requirements can be inferred
82 tee: &'a &'b T
83 }
84
85 struct TeeWhereOutlivesAyBeeIsDebug<'a, 'b, T> where T: Debug {
86 //~^ ERROR outlives requirements can be inferred
87 tee: &'a &'b T
88 }
89
90 struct TeeWhereIsDebugOutlivesAyBee<'a, 'b, T> where T: Debug {
91 //~^ ERROR outlives requirements can be inferred
92 tee: &'a &'b T
93 }
94
95 struct TeeYooOutlivesAy<'a, T, U> {
96 //~^ ERROR outlives requirements can be inferred
97 tee: T,
98 yoo: &'a U
99 }
100
101 struct TeeYooOutlivesAyIsDebug<'a, T, U: Debug> {
102 //~^ ERROR outlives requirements can be inferred
103 tee: T,
104 yoo: &'a U
105 }
106
107 struct TeeYooIsDebugOutlivesAy<'a, T, U: Debug> {
108 //~^ ERROR outlives requirements can be inferred
109 tee: T,
110 yoo: &'a U
111 }
112
113 struct TeeOutlivesAyYooIsDebug<'a, T, U: Debug> {
114 //~^ ERROR outlives requirements can be inferred
115 tee: &'a T,
116 yoo: U
117 }
118
119 struct TeeYooOutlivesAyBee<'a, 'b, T, U> {
120 //~^ ERROR outlives requirements can be inferred
121 tee: T,
122 yoo: &'a &'b U
123 }
124
125 struct TeeYooOutlivesAyBeeIsDebug<'a, 'b, T, U: Debug> {
126 //~^ ERROR outlives requirements can be inferred
127 tee: T,
128 yoo: &'a &'b U
129 }
130
131 struct TeeYooIsDebugOutlivesAyBee<'a, 'b, T, U: Debug> {
132 //~^ ERROR outlives requirements can be inferred
133 tee: T,
134 yoo: &'a &'b U
135 }
136
137 struct TeeOutlivesAyBeeYooIsDebug<'a, 'b, T, U: Debug> {
138 //~^ ERROR outlives requirements can be inferred
139 tee: &'a &'b T,
140 yoo: U
141 }
142
143 struct TeeYooWhereOutlivesAy<'a, T, U> {
144 //~^ ERROR outlives requirements can be inferred
145 tee: T,
146 yoo: &'a U
147 }
148
149 struct TeeYooWhereOutlivesAyIsDebug<'a, T, U> where U: Debug {
150 //~^ ERROR outlives requirements can be inferred
151 tee: T,
152 yoo: &'a U
153 }
154
155 struct TeeYooWhereIsDebugOutlivesAy<'a, T, U> where U: Debug {
156 //~^ ERROR outlives requirements can be inferred
157 tee: T,
158 yoo: &'a U
159 }
160
161 struct TeeOutlivesAyYooWhereIsDebug<'a, T, U> where U: Debug {
162 //~^ ERROR outlives requirements can be inferred
163 tee: &'a T,
164 yoo: U
165 }
166
167 struct TeeYooWhereOutlivesAyBee<'a, 'b, T, U> {
168 //~^ ERROR outlives requirements can be inferred
169 tee: T,
170 yoo: &'a &'b U
171 }
172
173 struct TeeYooWhereOutlivesAyBeeIsDebug<'a, 'b, T, U> where U: Debug {
174 //~^ ERROR outlives requirements can be inferred
175 tee: T,
176 yoo: &'a &'b U
177 }
178
179 struct TeeYooWhereIsDebugOutlivesAyBee<'a, 'b, T, U> where U: Debug {
180 //~^ ERROR outlives requirements can be inferred
181 tee: T,
182 yoo: &'a &'b U
183 }
184
185 struct TeeOutlivesAyBeeYooWhereIsDebug<'a, 'b, T, U> where U: Debug {
186 //~^ ERROR outlives requirements can be inferred
187 tee: &'a &'b T,
188 yoo: U
189 }
190
191 struct TeeWhereOutlivesAyYooWhereIsDebug<'a, T, U> where U: Debug {
192 //~^ ERROR outlives requirements can be inferred
193 tee: &'a T,
194 yoo: U
195 }
196
197 struct TeeWhereOutlivesAyBeeYooWhereIsDebug<'a, 'b, T, U> where U: Debug {
198 //~^ ERROR outlives requirements can be inferred
199 tee: &'a &'b T,
200 yoo: U
201 }
202
203
204 // But outlives inference for 'static lifetimes is under a separate
205 // feature-gate for now
206 // (https://github.com/rust-lang/rust/issues/44493#issuecomment-407846046).
207 struct StaticRef<T: 'static> {
208 field: &'static T
209 }
210
211
212 fn main() {}