@@ -1399,6 +1399,38 @@ struct Foo<T: 'static> {
1399
1399
```
1400
1400
"## ,
1401
1401
1402
+ E0312 : r##"
1403
+ A lifetime of reference outlives lifetime of borrowed content.
1404
+
1405
+ Erroneous code example:
1406
+
1407
+ ```compile_fail,E0312
1408
+ fn make_child<'human, 'elve>(x: &mut &'human isize, y: &mut &'elve isize) {
1409
+ *x = *y;
1410
+ // error: lifetime of reference outlives lifetime of borrowed content
1411
+ }
1412
+ ```
1413
+
1414
+ The compiler cannot determine if the `human` lifetime will live long enough
1415
+ to keep up on the elve one. To solve this error, you have to give an
1416
+ explicit lifetime hierarchy:
1417
+
1418
+ ```
1419
+ fn make_child<'human, 'elve: 'human>(x: &mut &'human isize,
1420
+ y: &mut &'elve isize) {
1421
+ *x = *y; // ok!
1422
+ }
1423
+ ```
1424
+
1425
+ Or use the same lifetime for every variable:
1426
+
1427
+ ```
1428
+ fn make_child<'elve>(x: &mut &'elve isize, y: &mut &'elve isize) {
1429
+ *x = *y; // ok!
1430
+ }
1431
+ ```
1432
+ "## ,
1433
+
1402
1434
E0398 : r##"
1403
1435
In Rust 1.3, the default object lifetime bounds are expected to change, as
1404
1436
described in RFC #1156 [1]. You are getting a warning because the compiler
@@ -1674,7 +1706,6 @@ register_diagnostics! {
1674
1706
// E0304, // expected signed integer constant
1675
1707
// E0305, // expected constant
1676
1708
E0311 , // thing may not live long enough
1677
- E0312 , // lifetime of reference outlives lifetime of borrowed content
1678
1709
E0313 , // lifetime of borrowed pointer outlives lifetime of captured variable
1679
1710
E0314 , // closure outlives stack frame
1680
1711
E0315 , // cannot invoke closure outside of its lifetime
0 commit comments