|
1 | 1 | #![allow(unused)]
|
2 | 2 | #![deny(explicit_outlives_requirements)]
|
3 | 3 |
|
4 |
| -use std::fmt::{Debug, Display}; |
5 | 4 |
|
6 | 5 | // These examples should live in edition-lint-infer-outlives.rs, but are split
|
7 | 6 | // into this separate file because they can't be `rustfix`'d (and thus, can't
|
8 | 7 | // be part of a `run-rustfix` test file) until rust-lang-nursery/rustfix#141
|
9 | 8 | // is solved
|
10 | 9 |
|
11 |
| -struct TeeOutlivesAyIsDebugBee<'a, 'b, T: 'a + Debug + 'b> { |
12 |
| - //~^ ERROR outlives requirements can be inferred |
13 |
| - tee: &'a &'b T |
| 10 | +mod structs { |
| 11 | + use std::fmt::Debug; |
| 12 | + |
| 13 | + struct TeeOutlivesAyIsDebugBee<'a, 'b, T: 'a + Debug + 'b> { |
| 14 | + //~^ ERROR outlives requirements can be inferred |
| 15 | + tee: &'a &'b T |
| 16 | + } |
| 17 | + |
| 18 | + struct TeeWhereOutlivesAyIsDebugBee<'a, 'b, T> where T: 'a + Debug + 'b { |
| 19 | + //~^ ERROR outlives requirements can be inferred |
| 20 | + tee: &'a &'b T |
| 21 | + } |
| 22 | + |
| 23 | + struct TeeYooOutlivesAyIsDebugBee<'a, 'b, T, U: 'a + Debug + 'b> { |
| 24 | + //~^ ERROR outlives requirements can be inferred |
| 25 | + tee: T, |
| 26 | + yoo: &'a &'b U |
| 27 | + } |
| 28 | + |
| 29 | + struct TeeOutlivesAyYooBeeIsDebug<'a, 'b, T: 'a, U: 'b + Debug> { |
| 30 | + //~^ ERROR outlives requirements can be inferred |
| 31 | + tee: &'a T, |
| 32 | + yoo: &'b U |
| 33 | + } |
| 34 | + |
| 35 | + struct TeeOutlivesAyYooIsDebugBee<'a, 'b, T: 'a, U: Debug + 'b> { |
| 36 | + //~^ ERROR outlives requirements can be inferred |
| 37 | + tee: &'a T, |
| 38 | + yoo: &'b U |
| 39 | + } |
| 40 | + |
| 41 | + struct TeeOutlivesAyYooWhereBee<'a, 'b, T: 'a, U> where U: 'b { |
| 42 | + //~^ ERROR outlives requirements can be inferred |
| 43 | + tee: &'a T, |
| 44 | + yoo: &'b U |
| 45 | + } |
| 46 | + |
| 47 | + struct TeeYooWhereOutlivesAyIsDebugBee<'a, 'b, T, U> where U: 'a + Debug + 'b { |
| 48 | + //~^ ERROR outlives requirements can be inferred |
| 49 | + tee: T, |
| 50 | + yoo: &'a &'b U |
| 51 | + } |
| 52 | + |
| 53 | + struct TeeOutlivesAyYooWhereBeeIsDebug<'a, 'b, T: 'a, U> where U: 'b + Debug { |
| 54 | + //~^ ERROR outlives requirements can be inferred |
| 55 | + tee: &'a T, |
| 56 | + yoo: &'b U |
| 57 | + } |
| 58 | + |
| 59 | + struct TeeOutlivesAyYooWhereIsDebugBee<'a, 'b, T: 'a, U> where U: Debug + 'b { |
| 60 | + //~^ ERROR outlives requirements can be inferred |
| 61 | + tee: &'a T, |
| 62 | + yoo: &'b U |
| 63 | + } |
| 64 | + |
| 65 | + struct TeeWhereOutlivesAyYooWhereBeeIsDebug<'a, 'b, T, U> where T: 'a, U: 'b + Debug { |
| 66 | + //~^ ERROR outlives requirements can be inferred |
| 67 | + tee: &'a T, |
| 68 | + yoo: &'b U |
| 69 | + } |
| 70 | + |
| 71 | + struct TeeWhereOutlivesAyYooWhereIsDebugBee<'a, 'b, T, U> where T: 'a, U: Debug + 'b { |
| 72 | + //~^ ERROR outlives requirements can be inferred |
| 73 | + tee: &'a T, |
| 74 | + yoo: &'b U |
| 75 | + } |
| 76 | + |
| 77 | + struct BeeOutlivesAyTeeBee<'a, 'b: 'a, T: 'b> { |
| 78 | + //~^ ERROR outlives requirements can be inferred |
| 79 | + tee: &'a &'b T, |
| 80 | + } |
| 81 | + |
| 82 | + struct BeeOutlivesAyTeeAyBee<'a, 'b: 'a, T: 'a + 'b> { |
| 83 | + //~^ ERROR outlives requirements can be inferred |
| 84 | + tee: &'a &'b T, |
| 85 | + } |
| 86 | + |
| 87 | + struct BeeOutlivesAyTeeOutlivesAyIsDebugBee<'a, 'b: 'a, T: 'a + Debug + 'b> { |
| 88 | + //~^ ERROR outlives requirements can be inferred |
| 89 | + tee: &'a &'b T |
| 90 | + } |
| 91 | + |
| 92 | + struct BeeWhereAyTeeWhereOutlivesAyIsDebugBee<'a, 'b, T> where 'b: 'a, T: 'a + Debug + 'b { |
| 93 | + //~^ ERROR outlives requirements can be inferred |
| 94 | + tee: &'a &'b T |
| 95 | + } |
| 96 | + |
| 97 | + struct BeeOutlivesAyTeeYooOutlivesAyIsDebugBee<'a, 'b: 'a, T, U: 'a + Debug + 'b> { |
| 98 | + //~^ ERROR outlives requirements can be inferred |
| 99 | + tee: T, |
| 100 | + yoo: &'a &'b U |
| 101 | + } |
| 102 | + |
| 103 | + struct BeeWhereAyTeeYooWhereOutlivesAyIsDebugBee<'a, 'b, T, U> |
| 104 | + where U: 'a + Debug + 'b, 'b: 'a |
| 105 | + //~^ ERROR outlives requirements can be inferred |
| 106 | + { |
| 107 | + tee: T, |
| 108 | + yoo: &'a &'b U |
| 109 | + } |
14 | 110 | }
|
15 | 111 |
|
16 |
| -struct TeeWhereOutlivesAyIsDebugBee<'a, 'b, T> where T: 'a + Debug + 'b { |
| 112 | +mod tuple_structs { |
| 113 | + use std::fmt::Debug; |
| 114 | + |
| 115 | + struct TeeOutlivesAyIsDebugBee<'a, 'b, T: 'a + Debug + 'b>(&'a &'b T); |
17 | 116 | //~^ ERROR outlives requirements can be inferred
|
18 |
| - tee: &'a &'b T |
19 |
| -} |
20 | 117 |
|
21 |
| -struct TeeYooOutlivesAyIsDebugBee<'a, 'b, T, U: 'a + Debug + 'b> { |
| 118 | + struct TeeWhereOutlivesAyIsDebugBee<'a, 'b, T>(&'a &'b T) where T: 'a + Debug + 'b; |
22 | 119 | //~^ ERROR outlives requirements can be inferred
|
23 |
| - tee: T, |
24 |
| - yoo: &'a &'b U |
25 |
| -} |
26 | 120 |
|
27 |
| -struct TeeOutlivesAyYooBeeIsDebug<'a, 'b, T: 'a, U: 'b + Debug> { |
| 121 | + struct TeeYooOutlivesAyIsDebugBee<'a, 'b, T, U: 'a + Debug + 'b>(T, &'a &'b U); |
28 | 122 | //~^ ERROR outlives requirements can be inferred
|
29 |
| - tee: &'a T, |
30 |
| - yoo: &'b U |
31 |
| -} |
32 | 123 |
|
33 |
| -struct TeeOutlivesAyYooIsDebugBee<'a, 'b, T: 'a, U: Debug + 'b> { |
| 124 | + struct TeeOutlivesAyYooBeeIsDebug<'a, 'b, T: 'a, U: 'b + Debug>(&'a T, &'b U); |
34 | 125 | //~^ ERROR outlives requirements can be inferred
|
35 |
| - tee: &'a T, |
36 |
| - yoo: &'b U |
37 |
| -} |
38 | 126 |
|
39 |
| -struct TeeOutlivesAyYooWhereBee<'a, 'b, T: 'a, U> where U: 'b { |
| 127 | + struct TeeOutlivesAyYooIsDebugBee<'a, 'b, T: 'a, U: Debug + 'b>(&'a T, &'b U); |
40 | 128 | //~^ ERROR outlives requirements can be inferred
|
41 |
| - tee: &'a T, |
42 |
| - yoo: &'b U |
43 |
| -} |
44 | 129 |
|
45 |
| -struct TeeYooWhereOutlivesAyIsDebugBee<'a, 'b, T, U> where U: 'a + Debug + 'b { |
| 130 | + struct TeeOutlivesAyYooWhereBee<'a, 'b, T: 'a, U>(&'a T, &'b U) where U: 'b; |
46 | 131 | //~^ ERROR outlives requirements can be inferred
|
47 |
| - tee: T, |
48 |
| - yoo: &'a &'b U |
49 |
| -} |
50 | 132 |
|
51 |
| -struct TeeOutlivesAyYooWhereBeeIsDebug<'a, 'b, T: 'a, U> where U: 'b + Debug { |
| 133 | + struct TeeYooWhereOutlivesAyIsDebugBee<'a, 'b, T, U>(T, &'a &'b U) where U: 'a + Debug + 'b; |
52 | 134 | //~^ ERROR outlives requirements can be inferred
|
53 |
| - tee: &'a T, |
54 |
| - yoo: &'b U |
55 |
| -} |
56 | 135 |
|
57 |
| -struct TeeOutlivesAyYooWhereIsDebugBee<'a, 'b, T: 'a, U> where U: Debug + 'b { |
| 136 | + struct TeeOutlivesAyYooWhereBeeIsDebug<'a, 'b, T: 'a, U>(&'a T, &'b U) where U: 'b + Debug; |
58 | 137 | //~^ ERROR outlives requirements can be inferred
|
59 |
| - tee: &'a T, |
60 |
| - yoo: &'b U |
61 |
| -} |
62 | 138 |
|
63 |
| -struct TeeWhereOutlivesAyYooWhereBeeIsDebug<'a, 'b, T, U> where T: 'a, U: 'b + Debug { |
| 139 | + struct TeeOutlivesAyYooWhereIsDebugBee<'a, 'b, T: 'a, U>(&'a T, &'b U) where U: Debug + 'b; |
| 140 | + //~^ ERROR outlives requirements can be inferred |
| 141 | + |
| 142 | + struct TeeWhereAyYooWhereBeeIsDebug<'a, 'b, T, U>(&'a T, &'b U) where T: 'a, U: 'b + Debug; |
| 143 | + //~^ ERROR outlives requirements can be inferred |
| 144 | + |
| 145 | + struct TeeWhereAyYooWhereIsDebugBee<'a, 'b, T, U>(&'a T, &'b U) where T: 'a, U: Debug + 'b; |
| 146 | + //~^ ERROR outlives requirements can be inferred |
| 147 | + |
| 148 | + struct BeeOutlivesAyTeeBee<'a, 'b: 'a, T: 'b>(&'a &'b T); |
| 149 | + //~^ ERROR outlives requirements can be inferred |
| 150 | + |
| 151 | + struct BeeOutlivesAyTeeAyBee<'a, 'b: 'a, T: 'a + 'b>(&'a &'b T); |
| 152 | + //~^ ERROR outlives requirements can be inferred |
| 153 | + |
| 154 | + struct BeeOutlivesAyTeeOutlivesAyIsDebugBee<'a, 'b: 'a, T: 'a + Debug + 'b>(&'a &'b T); |
| 155 | + //~^ ERROR outlives requirements can be inferred |
| 156 | + |
| 157 | + struct BeeWhereAyTeeWhereAyIsDebugBee<'a, 'b, T>(&'a &'b T) where 'b: 'a, T: 'a + Debug + 'b; |
64 | 158 | //~^ ERROR outlives requirements can be inferred
|
65 |
| - tee: &'a T, |
66 |
| - yoo: &'b U |
67 |
| -} |
68 | 159 |
|
69 |
| -struct TeeWhereOutlivesAyYooWhereIsDebugBee<'a, 'b, T, U> where T: 'a, U: Debug + 'b { |
| 160 | + struct BeeOutlivesAyTeeYooOutlivesAyIsDebugBee<'a, 'b: 'a, T, U: 'a + Debug + 'b>(T, &'a &'b U); |
70 | 161 | //~^ ERROR outlives requirements can be inferred
|
71 |
| - tee: &'a T, |
72 |
| - yoo: &'b U |
| 162 | + |
| 163 | + struct BeeWhereAyTeeYooWhereAyIsDebugBee<'a, 'b, T, U>(T, &'a &'b U) |
| 164 | + where U: 'a + Debug + 'b, 'b: 'a; |
| 165 | + //~^ ERROR outlives requirements can be inferred |
| 166 | +} |
| 167 | + |
| 168 | +mod enums { |
| 169 | + use std::fmt::Debug; |
| 170 | + |
| 171 | + enum TeeOutlivesAyIsDebugBee<'a, 'b, T: 'a + Debug + 'b> { |
| 172 | + //~^ ERROR outlives requirements can be inferred |
| 173 | + V { tee: &'a &'b T }, |
| 174 | + } |
| 175 | + |
| 176 | + enum TeeWhereOutlivesAyIsDebugBee<'a, 'b, T> where T: 'a + Debug + 'b { |
| 177 | + //~^ ERROR outlives requirements can be inferred |
| 178 | + V(&'a &'b T), |
| 179 | + } |
| 180 | + |
| 181 | + enum TeeYooOutlivesAyIsDebugBee<'a, 'b, T, U: 'a + Debug + 'b> { |
| 182 | + //~^ ERROR outlives requirements can be inferred |
| 183 | + V { tee: T, }, |
| 184 | + W(&'a &'b U), |
| 185 | + } |
| 186 | + |
| 187 | + enum TeeOutlivesAyYooBeeIsDebug<'a, 'b, T: 'a, U: 'b + Debug> { |
| 188 | + //~^ ERROR outlives requirements can be inferred |
| 189 | + V { tee: &'a T, yoo: &'b U }, |
| 190 | + W, |
| 191 | + } |
| 192 | + |
| 193 | + enum TeeOutlivesAyYooIsDebugBee<'a, 'b, T: 'a, U: Debug + 'b> { |
| 194 | + //~^ ERROR outlives requirements can be inferred |
| 195 | + V(&'a T, &'b U), |
| 196 | + W, |
| 197 | + } |
| 198 | + |
| 199 | + enum TeeOutlivesAyYooWhereBee<'a, 'b, T: 'a, U> where U: 'b { |
| 200 | + //~^ ERROR outlives requirements can be inferred |
| 201 | + V { tee: &'a T }, |
| 202 | + W(&'b U), |
| 203 | + } |
| 204 | + |
| 205 | + enum TeeYooWhereOutlivesAyIsDebugBee<'a, 'b, T, U> where U: 'a + Debug + 'b { |
| 206 | + //~^ ERROR outlives requirements can be inferred |
| 207 | + V { tee: T, yoo: &'a &'b U }, |
| 208 | + W, |
| 209 | + } |
| 210 | + |
| 211 | + enum TeeOutlivesAyYooWhereBeeIsDebug<'a, 'b, T: 'a, U> where U: 'b + Debug { |
| 212 | + //~^ ERROR outlives requirements can be inferred |
| 213 | + V(&'a T, &'b U), |
| 214 | + W, |
| 215 | + } |
| 216 | + |
| 217 | + enum TeeOutlivesAyYooWhereIsDebugBee<'a, 'b, T: 'a, U> where U: Debug + 'b { |
| 218 | + //~^ ERROR outlives requirements can be inferred |
| 219 | + V { tee: &'a T }, |
| 220 | + W(&'b U) |
| 221 | + } |
| 222 | + |
| 223 | + enum TeeWhereOutlivesAyYooWhereBeeIsDebug<'a, 'b, T, U> where T: 'a, U: 'b + Debug { |
| 224 | + //~^ ERROR outlives requirements can be inferred |
| 225 | + V { tee: &'a T, yoo: &'b U }, |
| 226 | + W, |
| 227 | + } |
| 228 | + |
| 229 | + enum TeeWhereOutlivesAyYooWhereIsDebugBee<'a, 'b, T, U> where T: 'a, U: Debug + 'b { |
| 230 | + //~^ ERROR outlives requirements can be inferred |
| 231 | + V(&'a T, &'b U), |
| 232 | + W, |
| 233 | + } |
| 234 | + |
| 235 | + enum BeeOutlivesAyTeeBee<'a, 'b: 'a, T: 'b> { |
| 236 | + //~^ ERROR outlives requirements can be inferred |
| 237 | + V { tee: &'a &'b T }, |
| 238 | + } |
| 239 | + |
| 240 | + enum BeeOutlivesAyTeeAyBee<'a, 'b: 'a, T: 'a + 'b> { |
| 241 | + //~^ ERROR outlives requirements can be inferred |
| 242 | + V { tee: &'a &'b T }, |
| 243 | + W, |
| 244 | + } |
| 245 | + |
| 246 | + enum BeeOutlivesAyTeeOutlivesAyIsDebugBee<'a, 'b: 'a, T: 'a + Debug + 'b> { |
| 247 | + //~^ ERROR outlives requirements can be inferred |
| 248 | + V { tee: &'a &'b T }, |
| 249 | + } |
| 250 | + |
| 251 | + enum BeeWhereAyTeeWhereOutlivesAyIsDebugBee<'a, 'b, T> where 'b: 'a, T: 'a + Debug + 'b { |
| 252 | + //~^ ERROR outlives requirements can be inferred |
| 253 | + V(&'a &'b T), |
| 254 | + } |
| 255 | + |
| 256 | + enum BeeOutlivesAyTeeYooOutlivesAyIsDebugBee<'a, 'b: 'a, T, U: 'a + Debug + 'b> { |
| 257 | + //~^ ERROR outlives requirements can be inferred |
| 258 | + V { tee: T }, |
| 259 | + W(&'a &'b U), |
| 260 | + } |
| 261 | + |
| 262 | + enum BeeWhereAyTeeYooWhereOutlivesAyIsDebugBee<'a, 'b, T, U> where U: 'a + Debug + 'b, 'b: 'a { |
| 263 | + //~^ ERROR outlives requirements can be inferred |
| 264 | + V { tee: T, yoo: &'a &'b U }, |
| 265 | + } |
| 266 | +} |
| 267 | + |
| 268 | +mod unions { |
| 269 | + use std::fmt::Debug; |
| 270 | + |
| 271 | + union TeeOutlivesAyIsDebugBee<'a, 'b, T: 'a + Debug + 'b> { |
| 272 | + //~^ ERROR outlives requirements can be inferred |
| 273 | + tee: &'a &'b T |
| 274 | + } |
| 275 | + |
| 276 | + union TeeWhereOutlivesAyIsDebugBee<'a, 'b, T> where T: 'a + Debug + 'b { |
| 277 | + //~^ ERROR outlives requirements can be inferred |
| 278 | + tee: &'a &'b T |
| 279 | + } |
| 280 | + |
| 281 | + union TeeYooOutlivesAyIsDebugBee<'a, 'b, T, U: 'a + Debug + 'b> { |
| 282 | + //~^ ERROR outlives requirements can be inferred |
| 283 | + tee: *const T, |
| 284 | + yoo: &'a &'b U |
| 285 | + } |
| 286 | + |
| 287 | + union TeeOutlivesAyYooBeeIsDebug<'a, 'b, T: 'a, U: 'b + Debug> { |
| 288 | + //~^ ERROR outlives requirements can be inferred |
| 289 | + tee: &'a T, |
| 290 | + yoo: &'b U |
| 291 | + } |
| 292 | + |
| 293 | + union TeeOutlivesAyYooIsDebugBee<'a, 'b, T: 'a, U: Debug + 'b> { |
| 294 | + //~^ ERROR outlives requirements can be inferred |
| 295 | + tee: &'a T, |
| 296 | + yoo: &'b U |
| 297 | + } |
| 298 | + |
| 299 | + union TeeOutlivesAyYooWhereBee<'a, 'b, T: 'a, U> where U: 'b { |
| 300 | + //~^ ERROR outlives requirements can be inferred |
| 301 | + tee: &'a T, |
| 302 | + yoo: &'b U |
| 303 | + } |
| 304 | + |
| 305 | + union TeeYooWhereOutlivesAyIsDebugBee<'a, 'b, T, U> where U: 'a + Debug + 'b { |
| 306 | + //~^ ERROR outlives requirements can be inferred |
| 307 | + tee: *const T, |
| 308 | + yoo: &'a &'b U |
| 309 | + } |
| 310 | + |
| 311 | + union TeeOutlivesAyYooWhereBeeIsDebug<'a, 'b, T: 'a, U> where U: 'b + Debug { |
| 312 | + //~^ ERROR outlives requirements can be inferred |
| 313 | + tee: &'a T, |
| 314 | + yoo: &'b U |
| 315 | + } |
| 316 | + |
| 317 | + union TeeOutlivesAyYooWhereIsDebugBee<'a, 'b, T: 'a, U> where U: Debug + 'b { |
| 318 | + //~^ ERROR outlives requirements can be inferred |
| 319 | + tee: &'a T, |
| 320 | + yoo: &'b U |
| 321 | + } |
| 322 | + |
| 323 | + union TeeWhereOutlivesAyYooWhereBeeIsDebug<'a, 'b, T, U> where T: 'a, U: 'b + Debug { |
| 324 | + //~^ ERROR outlives requirements can be inferred |
| 325 | + tee: &'a T, |
| 326 | + yoo: &'b U |
| 327 | + } |
| 328 | + |
| 329 | + union TeeWhereOutlivesAyYooWhereIsDebugBee<'a, 'b, T, U> where T: 'a, U: Debug + 'b { |
| 330 | + //~^ ERROR outlives requirements can be inferred |
| 331 | + tee: &'a T, |
| 332 | + yoo: &'b U |
| 333 | + } |
| 334 | + |
| 335 | + union BeeOutlivesAyTeeBee<'a, 'b: 'a, T: 'b> { |
| 336 | + //~^ ERROR outlives requirements can be inferred |
| 337 | + tee: &'a &'b T, |
| 338 | + } |
| 339 | + |
| 340 | + union BeeOutlivesAyTeeAyBee<'a, 'b: 'a, T: 'a + 'b> { |
| 341 | + //~^ ERROR outlives requirements can be inferred |
| 342 | + tee: &'a &'b T, |
| 343 | + } |
| 344 | + |
| 345 | + union BeeOutlivesAyTeeOutlivesAyIsDebugBee<'a, 'b: 'a, T: 'a + Debug + 'b> { |
| 346 | + //~^ ERROR outlives requirements can be inferred |
| 347 | + tee: &'a &'b T |
| 348 | + } |
| 349 | + |
| 350 | + union BeeWhereAyTeeWhereOutlivesAyIsDebugBee<'a, 'b, T> where 'b: 'a, T: 'a + Debug + 'b { |
| 351 | + //~^ ERROR outlives requirements can be inferred |
| 352 | + tee: &'a &'b T |
| 353 | + } |
| 354 | + |
| 355 | + union BeeOutlivesAyTeeYooOutlivesAyIsDebugBee<'a, 'b: 'a, T, U: 'a + Debug + 'b> { |
| 356 | + //~^ ERROR outlives requirements can be inferred |
| 357 | + tee: *const T, |
| 358 | + yoo: &'a &'b U |
| 359 | + } |
| 360 | + |
| 361 | + union BeeWhereAyTeeYooWhereOutlivesAyIsDebugBee<'a, 'b, T, U> where U: 'a + Debug + 'b, 'b: 'a { |
| 362 | + //~^ ERROR outlives requirements can be inferred |
| 363 | + tee: *const T, |
| 364 | + yoo: &'a &'b U |
| 365 | + } |
73 | 366 | }
|
74 | 367 |
|
75 | 368 | fn main() {}
|
0 commit comments