Skip to content

Commit 4ac3001

Browse files
committed
rustc_trans: don't do on-demand drop glue instantiation.
1 parent a2726f4 commit 4ac3001

File tree

4 files changed

+5
-18
lines changed

4 files changed

+5
-18
lines changed

src/librustc_trans/glue.rs

+2-18
Original file line numberDiff line numberDiff line change
@@ -216,30 +216,14 @@ fn get_drop_glue_core<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
216216
g: DropGlueKind<'tcx>) -> ValueRef {
217217
let g = g.map_ty(|t| get_drop_glue_type(ccx.tcx(), t));
218218
match ccx.drop_glues().borrow().get(&g) {
219-
Some(&(glue, _)) => return glue,
219+
Some(&(glue, _)) => glue,
220220
None => {
221-
debug!("Could not find drop glue for {:?} -- {} -- {}. \
222-
Falling back to on-demand instantiation.",
221+
bug!("Could not find drop glue for {:?} -- {} -- {}.",
223222
g,
224223
TransItem::DropGlue(g).to_raw_string(),
225224
ccx.codegen_unit().name());
226225
}
227226
}
228-
229-
// FIXME: #34151
230-
// Normally, getting here would indicate a bug in trans::collector,
231-
// since it seems to have missed a translation item. When we are
232-
// translating with non-MIR-based trans, however, the results of the
233-
// collector are not entirely reliable since it bases its analysis
234-
// on MIR. Thus, we'll instantiate the missing function on demand in
235-
// this codegen unit, so that things keep working.
236-
237-
TransItem::DropGlue(g).predefine(ccx, llvm::InternalLinkage);
238-
TransItem::DropGlue(g).define(ccx);
239-
240-
// Now that we made sure that the glue function is in ccx.drop_glues,
241-
// give it another try
242-
get_drop_glue_core(ccx, g)
243227
}
244228

245229
pub fn implement_drop_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,

src/test/codegen-units/item-collection/instantiation-through-vtable.rs

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ impl<T> Trait for Struct<T> {
3131
fn main() {
3232
let s1 = Struct { _a: 0u32 };
3333

34+
//~ TRANS_ITEM drop-glue i8
3435
//~ TRANS_ITEM fn instantiation_through_vtable::{{impl}}[0]::foo[0]<u32>
3536
//~ TRANS_ITEM fn instantiation_through_vtable::{{impl}}[0]::bar[0]<u32>
3637
let _ = &s1 as &Trait;

src/test/codegen-units/item-collection/unsizing.rs

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ fn main()
5757
{
5858
// simple case
5959
let bool_sized = &true;
60+
//~ TRANS_ITEM drop-glue i8
6061
//~ TRANS_ITEM fn unsizing::{{impl}}[0]::foo[0]
6162
let _bool_unsized = bool_sized as &Trait;
6263

src/test/codegen-units/partitioning/vtable-through-const.rs

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ mod mod1 {
6969

7070
//~ TRANS_ITEM fn vtable_through_const::main[0] @@ vtable_through_const[External]
7171
fn main() {
72+
//~ TRANS_ITEM drop-glue i8 @@ vtable_through_const[Internal]
7273

7374
// Since Trait1::do_something() is instantiated via its default implementation,
7475
// it is considered a generic and is instantiated here only because it is

0 commit comments

Comments
 (0)