-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-edition-2018Area: The 2018 editionArea: The 2018 editionC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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?)
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-edition-2018Area: The 2018 editionArea: The 2018 editionC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.