Closed
Description
I would expect this to compile but it doesn't:
struct Foo {
f: &'static [int]
}
fn main() {
Foo {
f: &'static [10]
};
}
test.rs:7:12: 7:25 error: cannot infer an appropriate lifetime for automatic coercion due to conflicting requirements
test.rs:7 f: &'static [10]
^~~~~~~~~~~~~
test.rs:6:5: 6:8 note: first, the lifetime cannot outlive the statement at 6:4...
test.rs:6 Foo {
^~~
test.rs:7:12: 7:25 note: ...so that reference does not outlive borrowed content
test.rs:7 f: &'static [10]
^~~~~~~~~~~~~
note: but, the lifetime must be valid for the static lifetime...
test.rs:7:12: 7:25 note: ...so that expression is assignable (expected `&'static [int]` but found `&[int]`)
test.rs:7 f: &'static [10]
^~~~~~~~~~~~~
error: aborting due to previous error
task 'rustc' failed at 'explicit failure', /build/rust-git/src/rust/src/libsyntax/diagnostic.rs:75
task '<main>' failed at 'explicit failure', /build/rust-git/src/rust/src/librustc/lib.rs:448