]> git.lizzy.rs Git - rust.git/commit
Don't call drop when taking the address of unsized fields
authorBjörn Steinbrink <bsteinbr@gmail.com>
Tue, 19 May 2015 07:50:48 +0000 (09:50 +0200)
committerBjörn Steinbrink <bsteinbr@gmail.com>
Tue, 19 May 2015 12:25:35 +0000 (14:25 +0200)
commitb802b187303ff3499849c5763d3dcd39f1b6c3cf
tree487080328072a479e7e36c1b4620c4604d077d3e
parent84b1e084862c08c19c36f0cf1f3698343c8ba7fa
Don't call drop when taking the address of unsized fields

When taking the address of an unsized field we generate a rvalue datum
for the field and then convert it to an lvalue datum. At that point,
cleanup is scheduled for the field, leading to multiple drop calls.

The problem is that we generate an rvalue datum for the field, since the
pointer does not own the data and there's already cleanup scheduled
elsewhere by the true owner. Instead, an lvalue datum must be created.

Thanks to @eddyb for identifying the underlying cause and suggesting the
correct fix.

Fixes #25549
Fixes #25515
src/librustc_trans/trans/expr.rs
src/test/run-pass/issue-25515.rs [new file with mode: 0644]
src/test/run-pass/issue-25549-multiple-drop.rs [new file with mode: 0644]