Closed
Description
The owning_ref crate has a couple test failures starting with Rust 1.23, which worked fine on 1.22. It is fixed by Kimundi/owning-ref-rs#43, but I wanted to see if this is a deliberate compiler change. The only compatibility note for 1.23 that sounds like it might be related is regarding #45852, but I'm not sure.
Reduced example, playground:
fn map<F, T, U>(x: &T, f: F) -> &U
where
F: FnOnce(&T) -> &U,
{
f(x)
}
fn borrow<'a>(a: &'a &[i32; 2]) -> &'a i32 {
&a[0]
}
fn main() {
let foo = [413, 612];
let bar = &foo;
map(&bar, borrow); // OK
map(&bar, |a: &&[i32; 2]| &a[0]); // does not live long enough
}
This example works on 1.22, but fails on 1.23 through nightly:
error[E0597]: `a[..]` does not live long enough
--> src/main.rs:18:32
|
18 | map(&bar, |a: &&[i32; 2]| &a[0]); // does not live long enough
| ^^^^- borrowed value only lives until here
| |
| does not live long enough
|
note: borrowed value must be valid for the anonymous lifetime #2 defined on the body at 18:15...
--> src/main.rs:18:15
|
18 | map(&bar, |a: &&[i32; 2]| &a[0]); // does not live long enough
| ^^^^^^^^^^^^^^^^^^^^^