-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[move-keyword] Change from using a move function -> move keyword. #60404
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
[move-keyword] Change from using a move function -> move keyword. #60404
Conversation
@swift-ci test |
@@ -357,6 +367,13 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC, | |||
} | |||
} | |||
|
|||
void checkMoveExpr(MoveExpr *moveExpr) { | |||
if (!isa<DeclRefExpr>(moveExpr->getSubExpr())) { | |||
Ctx.Diags.diagnose(moveExpr->getLoc(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jckarter do you think I need to check for more things here? When I talked with @DougGregor he mentioned to check that this check also catches field accesses (which it does)... but I figured I would ask out of an abundance of caution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that we need an ironclad AST-level diagnostic here, since we will still need a diagnostic in SIL anyway to detect lvalues that can't be statically moved. So I think this is fine to reject obviously unsupportable cases.
Another additional nice thing is that b/c the SILGen emission always works pretty much how I want it, I don't need to rely upon the move function canonicalization pass. I am going to rip that out in a subsequent PR. |
085642c
to
ae00539
Compare
Test failed b/c in the mean time someone added another syntax node so there was a node numbering collision. I just rebased/added one to MoveExpr's serialization number. |
@swift-ci test |
ae00539
to
2874760
Compare
@swift-ci test |
2874760
to
c670516
Compare
It doesn't do anything yet.
I did this by requiring this in the typechecker. This will ensure that when we emit a move, we are guaranteed to have a value decl ref that we can evaluate. It also ensures that we can't _move fields. auto
…emission. I also updated the move function tests to show that this is working. As a nice bonus, I was able to enable all of the tests also in a non-optimized stdlib.
c670516
to
e9d8f36
Compare
Swift syntax PR: swiftlang/swift-syntax#563 |
@gottesmm This is breaking a library I actively maintain. There is a function called Reported in: #60492 Final reproducer: #60492 (comment) If this is desired behavior, could we incorporate my reproducer into the Swift test suite, so that it's explicit that we want such code to fail? |
@philipturner I actually put it behind an option in a subsequent so it shouldn't break you. The final name is still under discussion, but once that is finalized, I am happy to add a test. |
I already escaped |
This PR does 2 things: