2 use rustc::ty::adjustment::CustomCoerceUnsized;
3 use rustc::ty::{self, Ty, TyCtxt};
8 pub fn custom_coerce_unsize_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11 -> CustomCoerceUnsized {
12 let def_id = tcx.lang_items().coerce_unsized_trait().unwrap();
14 let trait_ref = ty::Binder::bind(ty::TraitRef {
16 substs: tcx.mk_substs_trait(source_ty, &[target_ty.into()])
19 match tcx.codegen_fulfill_obligation( (ty::ParamEnv::reveal_all(), trait_ref)) {
20 traits::VtableImpl(traits::VtableImplData { impl_def_id, .. }) => {
21 tcx.coerce_unsized_info(impl_def_id).custom_kind.unwrap()
24 bug!("invalid CoerceUnsized vtable: {:?}", vtable);