Closed
Description
The following code:
struct Bar<'b> {
_field : &'b [u8]
}
struct Foo<'a, 'b> {
_field: &'a Bar<'b>
}
fn main() {
}
Playpen: http://is.gd/oPQAxE
Gives the errors:
<anon>:4:1: 6:2 error: in type `&'a Bar<'b>`, reference has a longer lifetime than the data it references
<anon>:4 struct Foo<'a, 'b> {
<anon>:5 _field: &'a Bar<'b>
<anon>:6 }
<anon>:4:1: 6:2 note: the pointer is valid for the lifetime 'a as defined on the struct at 4:0
<anon>:4 struct Foo<'a, 'b> {
<anon>:5 _field: &'a Bar<'b>
<anon>:6 }
<anon>:4:1: 6:2 note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 4:0
<anon>:4 struct Foo<'a, 'b> {
<anon>:5 _field: &'a Bar<'b>
<anon>:6 }
error: aborting due to previous error
playpen: application terminated with error code 101
Program ended.
Despite the lifetimes of 'a
and 'b
not having been bound yet.
This is happens using rustc 0.12.0-pre (23c1f9b3c 2014-08-30 21:51:25 +0000)
.
Metadata
Metadata
Assignees
Labels
No labels