Open
Description
I compiled a rather old project of mine for the first time in quite a while and was surprised that it no longer compiled on stable, which it did way back in 1.34.
Non-minimized regression demo: https://rust.godbolt.org/z/f9n6h8
The core of the problem is this bit of code:
if x == y {
return false;
}
let [x, y] = unsafe {
let x: *mut _ = &mut self.0.get_unchecked_mut(x);
let y: *mut _ = &mut self.0.get_unchecked_mut(y);
debug_assert_ne!(x, y);
[&mut *x, &mut *y]
};
It turns out that it was always wrong -- I meant to get a *mut Entry
, not a *mut &mut Entry
-- so I think this is probably an allowed breaking change?
But it's not documented in the release notes for 1.35, which surprised me.
It's not obvious to me exactly what got fixed here. Is a temporary lifetime different, or is borrowck just detecting something it didn't used to? (Both examples are on edition 2018, so I think MIR borrowck?)