Skip to content

Commit dfe660e

Browse files
Add E0478 error explanation
1 parent 599f1b9 commit dfe660e

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/librustc/diagnostics.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,37 @@ fn main() {
15271527
```
15281528
"##,
15291529

1530+
E0478: r##"
1531+
A lifetime bound was not satisfied.
1532+
1533+
Erroneous code example:
1534+
1535+
// Check that the explicit lifetime bound (`'b`, in this example) must
1536+
// outlive all the superbound from the trait (`'a`, in this example).
1537+
1538+
```compile_fail,E0478
1539+
trait Wedding<'t>: 't { }
1540+
1541+
struct Prince<'kiss, 'SnowWhite> {
1542+
child: Box<Wedding<'kiss> + 'SnowWhite>,
1543+
// error: lifetime bound not satisfied
1544+
}
1545+
```
1546+
1547+
In this example, the `'SnowWhite` lifetime is supposed to outlive the `'kiss`
1548+
lifetime but the declaration of the `Prince` struct doesn't enforce it. To fix
1549+
this issue, you need to specify it:
1550+
1551+
```
1552+
trait Wedding<'t>: 't { }
1553+
1554+
struct Prince<'kiss, 'SnowWhite: 'kiss> { // You say here that 'b must live
1555+
// longer than 'a.
1556+
child: Box<Wedding<'kiss> + 'SnowWhite>, // And now it's all good!
1557+
}
1558+
```
1559+
"##,
1560+
15301561
E0496: r##"
15311562
A lifetime name is shadowing another lifetime name. Erroneous code example:
15321563
@@ -1715,7 +1746,6 @@ register_diagnostics! {
17151746
E0475, // index of slice outside its lifetime
17161747
E0476, // lifetime of the source pointer does not outlive lifetime bound...
17171748
E0477, // the type `..` does not fulfill the required lifetime...
1718-
E0478, // lifetime bound not satisfied
17191749
E0479, // the type `..` (provided as the value of a type parameter) is...
17201750
E0480, // lifetime of method receiver does not outlive the method call
17211751
E0481, // lifetime of function argument does not outlive the function call

0 commit comments

Comments
 (0)