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