Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upBinding subpattern with @ allows for illegal mutation #14587
Comments
sfackler
added
the
I-wrong
label
Jun 1, 2014
This comment has been minimized.
This comment has been minimized.
|
That sounds quite bad, nominating. |
alexcrichton
added
the
I-nominated
label
Jun 2, 2014
This comment has been minimized.
This comment has been minimized.
|
P-backcompat-lang, 1.0. |
pnkfelix
added
the
P-backcompat-lang
label
Jun 5, 2014
pnkfelix
added this to the 1.0 milestone
Jun 5, 2014
pnkfelix
removed
the
I-nominated
label
Jun 5, 2014
This comment has been minimized.
This comment has been minimized.
|
cc me |
This comment has been minimized.
This comment has been minimized.
|
Ah, I think I know why this happens. Fascinating. It's no doubt because the matched expression is an rvalue. I think we'll have to upgrade how rvalues are handled in borrowck to fix this. |
This comment has been minimized.
This comment has been minimized.
|
cc #12534 |
pcwalton
assigned
nikomatsakis
Jun 26, 2014
This comment has been minimized.
This comment has been minimized.
|
Basically the problem is that we treat rvalues as though they are only ever once -- but with a devious match expression like this one you can arrange to consume them / borrow them multiple times. I think we ought to modify the memcategorization to store the expr-id of the rvalue and not just the temporary scope -- the borrow checker can then treat rvalues just as it treats lvalues. Basically we want to have the borrow checker reason about the temporary that will be created. |
Marwes commentedJun 1, 2014
This code compiles even though it should be rejected since writing to z invalidates the a variable.