-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Borrow checker on beta rejects code accepted on stable. #60927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We're cutting off a new stable next week, we should prioritize investigating and fixing this. |
Maximally reduced (playpen): pub fn bar<'a>(this: &'a mut ((), &'static ())) {
let beta = from(&this.0);
let locked = as_ref(&beta);
write(&mut this.1, locked);
}
fn write<T>(_: *mut T, _: T) {}
fn from<'a>(_: &'a ()) -> &'static () { panic!() }
fn as_ref<'a>(_: &'a &'static ()) -> &'a () { panic!() } |
Probably #58673, which fixed pointer casts being able to launder lifetimes with NLL. |
@matthewjasper any idea on how we'd be able to fix this in time for the release? Either by backporting or by fixing the actual bug? |
The example provided should be using |
Yeah that works. |
Hmm. Was I wrong about PR #58673 only affecting code opting in via Update: Ah! I figured out why NLL migrate mode does not "save" us here: The NLL error being signaled would only be downgraded to a warning if the AST-borrowck accepted the code. But the AST-borrowck rejects this code (or at least, it rejects the minimized example provided by @Centril , as you can see on this playpen). And therefore, we have a case where NLL previously accepted some code (but AST-borrowck rejected it), and now with PR #58673 in place, NLL rejects it with a hard error (because the migrate mode, upon inspecting the behavior of AST-borrowck, does not do the downgrade-to-warning). |
Me and @pnkfelix discussed this on Discord. The beta to stable promotion is happening today so there is no time for the compiler team to decide what's the best fix for this issue, and we don't want to rush things. I'm going to back out PR #58673 from the 1.35.0 release, but it will still be present on beta 1.36.0 and nightly, giving the teams more breathing room to reach a decision. |
An update: backing out the change doesn't seem to be trivial so I'm going to do the initial stable PR without it (aka with the regression). When I tried doing the revert I got a bunch of ICEs both in the test suite and while compiling stage1 rustc, so the backout seems risky enough not to do it right before 1.35.0 goes out. cc @rust-lang/release |
Can we mention this in the release blog post so people are warned? |
Assigning myself as a reminder re. blog post (but not for anything else). |
triage: I don't think we're going to try to "fix" the regression here. From the investigation documented above, it seems like acceptable fallout from a soundness fix; a warning-cycle would have been nice, but its not a necessity, and its not going to block the release. Removing I-nominated tag, and not going to add a priority label. Leaving assigned to @Centril regarding messaging. |
Decided not to include in blogpost or relnotes. Closing therefore. |
See the repo at https://github.com/khuey/rust-nightly-borrow-checker-failure
This repository builds on 1.34.2. It fails on 1.35.0-beta.8 with
The text was updated successfully, but these errors were encountered: