Auto merge of #36468 - michaelwoerister:collect-vtable-drop-glue, r=eddyb

trans: Let the collector find drop-glue for all vtables, not just VTableImpl.

This fixes #36260. So far, the collector has only recorded drop-glue for insertion into a vtable if the vtable was for an impl. But there's actually no reason why it shouldn't do just the same for closure vtables, afaict.

r? @eddyb
cc @rust-lang/compiler
This commit is contained in:
bors 2016-09-16 19:52:53 -07:00 committed by GitHub
commit 9dc9f340cc
5 changed files with 29 additions and 12 deletions

View file

@ -40,5 +40,3 @@ fn main() {
//~ TRANS_ITEM fn instantiation_through_vtable::{{impl}}[0]::bar[0]<u64>
let _ = &s1 as &Trait;
}
//~ TRANS_ITEM drop-glue i8

View file

@ -78,5 +78,3 @@ fn main()
//~ TRANS_ITEM fn unsizing::{{impl}}[3]::foo[0]
let _wrapper_sized = wrapper_sized as Wrapper<Trait>;
}
//~ TRANS_ITEM drop-glue i8

View file

@ -89,5 +89,3 @@ fn main() {
//~ TRANS_ITEM fn vtable_through_const::mod1[0]::id[0]<char> @@ vtable_through_const[Internal]
mod1::ID_CHAR('x');
}
//~ TRANS_ITEM drop-glue i8

View file

@ -0,0 +1,22 @@
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Make sure this compiles without getting a linker error because of missing
// drop-glue because the collector missed adding drop-glue for the closure:
fn create_fn() -> Box<Fn()> {
let text = String::new();
Box::new(move || { let _ = &text; })
}
fn main() {
let _ = create_fn();
}