]> git.proxmox.com Git - rustc.git/blob - src/librustc_error_codes/error_codes/E0478.md
New upstream version 1.47.0+dfsg1
[rustc.git] / src / librustc_error_codes / error_codes / E0478.md
1 A lifetime bound was not satisfied.
2
3 Erroneous code example:
4
5 ```compile_fail,E0478
6 // Check that the explicit lifetime bound (`'SnowWhite`, in this example) must
7 // outlive all the superbounds from the trait (`'kiss`, in this example).
8
9 trait Wedding<'t>: 't { }
10
11 struct Prince<'kiss, 'SnowWhite> {
12 child: Box<Wedding<'kiss> + 'SnowWhite>,
13 // error: lifetime bound not satisfied
14 }
15 ```
16
17 In this example, the `'SnowWhite` lifetime is supposed to outlive the `'kiss`
18 lifetime but the declaration of the `Prince` struct doesn't enforce it. To fix
19 this issue, you need to specify it:
20
21 ```
22 trait Wedding<'t>: 't { }
23
24 struct Prince<'kiss, 'SnowWhite: 'kiss> { // You say here that 'SnowWhite
25 // must live longer than 'kiss.
26 child: Box<Wedding<'kiss> + 'SnowWhite>, // And now it's all good!
27 }
28 ```