Allow let bindings and destructuring in constants and const fn#49172
Allow let bindings and destructuring in constants and const fn#49172bors merged 6 commits intorust-lang:masterfrom
Conversation
There was a problem hiding this comment.
Can you move this into local_qualif?
There was a problem hiding this comment.
This seems bad, because statement_like is used for a lot of errors - it should maybe be split into several functions?
There was a problem hiding this comment.
I think you want to replace the qualif always (e.g. let mut x = None; x = Some(TypeThatNeedsDrop);).
Also, if you have this special case, why do you need to do anything about statement_like?
There was a problem hiding this comment.
This is bad because it breaks promotion in const fn. Also, you want mutable borrows to locals outside of const fn too, right? I think we should orthogonally allow &mut foo in regular static, so only const needs a special-case at the outermost level (and promotion also needs to keep disallowing &mut NotZST).
|
@oli-obk If you want to get this merged quickly, I'd suggest dropping the borrowing changes. cc @nikomatsakis A bit of a conundrum: But we do want to allow |
|
I removed the borrowing changes |
|
Ping from triage, @eddyb ! |
|
This is very low priority atm. We could close it until after the next beta cut. |
|
Ping from triage @eddyb! This PR needs your review. |
|
Ping from triage! Can @eddyb or someone else from @rust-lang/compiler review this? |
There was a problem hiding this comment.
Isn't this condition flipped? EDIT: this appears to be the same for all allows_unstable.
There was a problem hiding this comment.
I would instead put an if around all the code below, just to make sure it's explicit.
|
Note to self. more tests: // ok
const X: FakeNeedsDrop = { let x = FakeNeedsDrop; x };
// error
const Y: FakeNeedsDrop = { let mut x = FakeNeedsDrop; x = FakeNeedsDrop; x };
// error
const Z: () = { let mut x = None; x = Some(FakeNeedsDrop); } |
|
Ping from triage @oli-obk ! Any time to work on this in the near future? |
This comment has been minimized.
This comment has been minimized.
|
Ping from triage @eddyb! This PR needs your review. |
|
#50603 has been merged. |
|
amazingly there are no conflicts whatsoever. @eddyb this is ready for another review |
There was a problem hiding this comment.
Can you combine these two match arms?
|
r=me with the nit fixed |
|
@bors r=eddyb |
|
📌 Commit 2483c81 has been approved by |
|
☀️ Test successful - status-appveyor, status-travis |
|
This PR needs to be backported to beta in order to backport #50909. cc @rust-lang/compiler |
|
i can create a version of #50909 that doesn't depend on this, it's just a debug statement that conflicts |
|
@oli-obk that would be awesome! |
r? @eddyb
cc #48821