Skip to content

Commit 9336805

Browse files
committed
mir: Don't forget to drop arguments.
1 parent f47d7c7 commit 9336805

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/librustc_mir/build/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,17 @@ impl<'a,'tcx> Builder<'a,'tcx> {
141141
.chain(explicits)
142142
.enumerate()
143143
.map(|(index, (ty, pattern))| {
144+
let lvalue = Lvalue::Arg(index as u32);
144145
if let Some(pattern) = pattern {
145-
let lvalue = Lvalue::Arg(index as u32);
146146
let pattern = this.hir.irrefutable_pat(pattern);
147147
unpack!(block = this.lvalue_into_pattern(block,
148148
argument_extent,
149149
pattern,
150150
&lvalue));
151151
}
152+
// Make sure we drop (parts of) the argument even when not matched on.
153+
this.schedule_drop(pattern.as_ref().map_or(ast_block.span, |pat| pat.span),
154+
argument_extent, &lvalue, ty);
152155
ArgDecl { ty: ty, spread: false }
153156
})
154157
.collect();

0 commit comments

Comments
 (0)