-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Parameter patterns are dropped *after* arguments #36088
Comments
Really, I'd expect |
@arielb1 What's the status of this? |
This does look somewhat expected to me - |
This still exists. With NLL it can't cause any soundness problems, but it just feels weird to me. Whatever we choose, this needs to be documented in the reference near the temporary lifetimes documentation. Not quite. The drop of both the arguments and the patterns happens at the function end, not at function start (see my edited post). |
iirc @matthewjasper has a PR to document this, rust-lang/reference#514 (I need to get back to it soon). Also, to fix a regression, we recently changed the drop semantics so that the drop order is |
Sure enough, this was fixed in #56044, with a test. Closing. |
Meta
STR
Actual Result
Explanation
When the function exits, the argument
arg0
is dropped first, followed by the variablevar0
akay
. This is the reverse of what happened in old trans, and looks quite unnatural. OTOH, it is quite similar tolet
-bindings, so maybe that is for the best.Relation to
match
statementsI don't think that lifetimes in
match
patterns are a good example for anything (see #46525), but amatch
statement drops the discriminant last:prints
The text was updated successfully, but these errors were encountered: