pub fn read_drop_type_from_vtable(
        &self,
        vtable: Scalar<M::PointerTag>,
    ) -> InterpResult<'tcx, (ty::Instance<'tcx>, Ty<'tcx>)> {
        let pointer_size = self.pointer_size();
        // We don't care about the pointee type; we just want a pointer.
        let vtable = self
            .memory
            .get(
                vtable,
                pointer_size * u64::try_from(COMMON_VTABLE_ENTRIES.len()).unwrap(),
                self.tcx.data_layout.pointer_align.abi,
            )?
            .expect("cannot be a ZST");
        let drop_fn = vtable
            .read_ptr_sized(
                pointer_size * u64::try_from(COMMON_VTABLE_ENTRIES_DROPINPLACE).unwrap(),
            )?
            .check_init()?;
        // We *need* an instance here, no other kind of function value, to be able
        // to determine the type.
        let drop_instance = self.memory.get_fn(drop_fn)?.as_instance()?;
        trace!("Found drop fn: {:?}", drop_instance);
        let fn_sig = drop_instance.ty(*self.tcx, self.param_env).fn_sig(*self.tcx);
        let fn_sig = self.tcx.normalize_erasing_late_bound_regions(self.param_env, fn_sig);
        // The drop function takes `*mut T` where `T` is the type being dropped, so get that.
        let args = fn_sig.inputs();
        if args.len() != 1 {
            throw_ub!(InvalidVtableDropFn(fn_sig));
        }
        let ty =
            args[0].builtin_deref(true).ok_or_else(|| err_ub!(InvalidVtableDropFn(fn_sig)))?.ty;
        Ok((drop_instance, ty))
    }
/// Returns the drop fn instance as well as the actual dynamic type.
Returns the drop fn instance as well as the actual dynamic type.
Returns the drop fn instance as well as the actual dynamic type .
pub fn read_drop_type_from_vtable(
        &self,
        vtable: Scalar<M::PointerTag>,
    ) -> InterpResult<'tcx, (ty::Instance<'tcx>, Ty<'tcx>)> {
        let pointer_size = self.pointer_size();
        // We don't care about the pointee type; we just want a pointer.
        let vtable = self
            .memory
            .get(
                vtable,
                pointer_size * u64::try_from(COMMON_VTABLE_ENTRIES.len()).unwrap(),
                self.tcx.data_layout.pointer_align.abi,
            )?
            .expect("cannot be a ZST");
        let drop_fn = vtable
            .read_ptr_sized(
                pointer_size * u64::try_from(COMMON_VTABLE_ENTRIES_DROPINPLACE).unwrap(),
            )?
            .check_init()?;
        // We *need* an instance here, no other kind of function value, to be able
        // to determine the type.
        let drop_instance = self.memory.get_fn(drop_fn)?.as_instance()?;
        trace!("Found drop fn: {:?}", drop_instance);
        let fn_sig = drop_instance.ty(*self.tcx, self.param_env).fn_sig(*self.tcx);
        let fn_sig = self.tcx.normalize_erasing_late_bound_regions(self.param_env, fn_sig);
        // The drop function takes `*mut T` where `T` is the type being dropped, so get that.
        let args = fn_sig.inputs();
        if args.len() != 1 {
            throw_ub!(InvalidVtableDropFn(fn_sig));
        }
        let ty =
            args[0].builtin_deref(true).ok_or_else(|| err_ub!(InvalidVtableDropFn(fn_sig)))?.ty;
        Ok((drop_instance, ty))
    }
pub fn read_drop_type_from_vtable ( & self , vtable : Scalar < M :: PointerTag > , ) -> InterpResult < ' tcx , ( ty :: Instance < ' tcx > , Ty < ' tcx > ) > { let pointer_size = self . pointer_size ( ) ; // We don't care about the pointee type; we just want a pointer. let vtable = self . memory . get ( vtable , pointer_size * u64 :: try_from ( COMMON_VTABLE_ENTRIES . len ( ) ) . unwrap ( ) , self . tcx . data_layout . pointer_align . abi , ) ? . expect ( " " ) ; let drop_fn = vtable . read_ptr_sized ( pointer_size * u64 :: try_from ( COMMON_VTABLE_ENTRIES_DROPINPLACE ) . unwrap ( ) , ) ? . check_init ( ) ? ; // We *need* an instance here, no other kind of function value, to be able // to determine the type. let drop_instance = self . memory . get_fn ( drop_fn ) ? . as_instance ( ) ? ; trace ! ( " " drop_instance ) ; let fn_sig = drop_instance . ty ( * self . tcx , self . param_env ) . fn_sig ( * self . tcx ) ; let fn_sig = self . tcx . normalize_erasing_late_bound_regions ( self . param_env , fn_sig ) ; // The drop function takes `*mut T` where `T` is the type being dropped, so get that. let args = fn_sig . inputs ( ) ; if args . len ( ) != 1 { throw_ub ! ( InvalidVtableDropFn ( fn_sig ) ) ; } let ty = args [ 0 ] . builtin_deref ( true ) . ok_or_else ( | | err_ub ! ( InvalidVtableDropFn ( fn_sig ) ) ) ? . ty ; Ok ( ( drop_instance , ty ) ) }
Returns the drop fn instance as well as the actual dynamic type.
Returns the drop fn instance as well as the actual dynamic type .
&self
vtable
Scalar<M::PointerTag>
&self
vtable
Scalar<M::PointerTag>