-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
Labels
A-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Description
Meta
$ rustc -V
rustc 1.13.0-dev (528c6f3ed 2016-08-25)
STR
struct NoisyDrop(&'static str);
impl Drop for NoisyDrop {
fn drop(&mut self) {
println!("dropping {}", self.0);
}
}
fn argument_buf((_,v,_): (NoisyDrop, NoisyDrop, NoisyDrop)) {
println!("in argument_buf");
}
fn main() {
argument_buf((NoisyDrop("x"), NoisyDrop("y"), NoisyDrop("z")));
}Actual Result
in argument_buf
dropping x
dropping z
dropping y
Explanation
When the function exits, the argument arg0 is dropped first, followed by the variable var0 aka y. This is the reverse of what happened in old trans, and looks quite unnatural. OTOH, it is quite similar to let-bindings, so maybe that is for the best.
Relation to match statements
I don't think that lifetimes in match patterns are a good example for anything (see #46525), but a match statement drops the discriminant last:
match (NoisyDrop("x"), NoisyDrop("y"), NoisyDrop("z")) {
(_, v, _) => println!("in match")
}prints
in match
dropping y
dropping x
dropping z
lambda-fairy
Metadata
Metadata
Assignees
Labels
A-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team