-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
unsoundness caused by hidden borrow in nightly match ergonomics #49631
Comments
Note that this is not a problem when using NLL: playground link. |
Sigh. It works with an explicit ref, as well, which suggests that the problem is the ExprUseVisitor. |
OK, so I found the bug. Not sure yet what is best fix. Let me write out what is going on:
rust/src/librustc/middle/mem_categorization.rs Line 1265 in 56714ac
So we need to stop doing that. Ah, I guess the rust/src/librustc/ty/context.rs Lines 368 to 381 in 56714ac
|
I think we should not stabilize language features right before beta is branched. I don't know if this issue in particular is big deal to backport or not, but stabilizing things at the begging/middle of the cycle avoids rushing to stabilize and then rushing to fix and backport regressions. |
( Fix in #49714 ) |
@leodasvacas
In this case, the fix is trivial -- you can see #49714. In general, we thought about trying to time landings into the middle of the cycle back in the early days, but we wound up concluding that there is no "right time" to land something. Any change can break stuff, of course, and wherever we draw the line, we've got a shot at getting something breaking. So I don't know. Maybe it's worth putting rules against stabilizing, but I kinda don't think so. At worst we can "unstabilize" (which I fear we will have to do for |
Playground
Output:
The above code should fail the borrow checker. They key line seems to be the pattern match. It creates a borrow that seems to be invisible to the borrow checker. This appears to only be possible in nightly due to the
match_default_bindings
feature.The text was updated successfully, but these errors were encountered: