Closed
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