Skip to content

Commit 8b94267

Browse files
trans: Make the trans-item collector see through VTableFnPointer.
1 parent ab8fff2 commit 8b94267

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/librustc_trans/collector.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -919,10 +919,19 @@ fn do_static_trait_method_dispatch<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
919919
fn_once_adjustment: fn_once_adjustment,
920920
}
921921
}
922-
// Trait object and function pointer shims are always
923-
// instantiated in-place, and as they are just an ABI-adjusting
924-
// indirect call they do not have any dependencies.
925-
traits::VtableFnPointer(..) |
922+
traits::VtableFnPointer(ref data) => {
923+
// If we know the destination of this fn-pointer, we'll have to make
924+
// sure that this destination actually gets instantiated.
925+
if let ty::TyFnDef(def_id, substs, _) = data.fn_ty.sty {
926+
// The destination of the pointer might be something that needs
927+
// further dispatching, such as a trait method, so we do that.
928+
do_static_dispatch(scx, def_id, substs, param_substs)
929+
} else {
930+
StaticDispatchResult::Unknown
931+
}
932+
}
933+
// Trait object shims are always instantiated in-place, and as they are
934+
// just an ABI-adjusting indirect call they do not have any dependencies.
926935
traits::VtableObject(..) => {
927936
StaticDispatchResult::Unknown
928937
}

0 commit comments

Comments
 (0)