pub fn destructor_constraints(self, def: &'tcx ty::AdtDef)
                                  -> Vec<ty::subst::GenericArg<'tcx>>
    {
        let dtor = match def.destructor(self) {
            None => {
                debug!("destructor_constraints({:?}) - no dtor", def.did);
                return vec![]
            }
            Some(dtor) => dtor.did
        };

        let impl_def_id = self.associated_item(dtor).container.id();
        let impl_generics = self.generics_of(impl_def_id);

        // We have a destructor - all the parameters that are not
        // pure_wrt_drop (i.e, don't have a #[may_dangle] attribute)
        // must be live.

        // We need to return the list of parameters from the ADTs
        // generics/substs that correspond to impure parameters on the
        // impl's generics. This is a bit ugly, but conceptually simple:
        //
        // Suppose our ADT looks like the following
        //
        //     struct S<X, Y, Z>(X, Y, Z);
        //
        // and the impl is
        //
        //     impl<#[may_dangle] P0, P1, P2> Drop for S<P1, P2, P0>
        //
        // We want to return the parameters (X, Y). For that, we match
        // up the item-substs <X, Y, Z> with the substs on the impl ADT,
        // <P1, P2, P0>, and then look up which of the impl substs refer to
        // parameters marked as pure.

        let impl_substs = match self.type_of(impl_def_id).kind {
            ty::Adt(def_, substs) if def_ == def => substs,
            _ => bug!()
        };

        let item_substs = match self.type_of(def.did).kind {
            ty::Adt(def_, substs) if def_ == def => substs,
            _ => bug!()
        };

        let result = item_substs.iter().zip(impl_substs.iter())
            .filter(|&(_, &k)| {
                match k.unpack() {
                    GenericArgKind::Lifetime(&ty::RegionKind::ReEarlyBound(ref ebr)) => {
                        !impl_generics.region_param(ebr, self).pure_wrt_drop
                    }
                    GenericArgKind::Type(&ty::TyS {
                        kind: ty::Param(ref pt), ..
                    }) => {
                        !impl_generics.type_param(pt, self).pure_wrt_drop
                    }
                    GenericArgKind::Const(&ty::Const {
                        val: ty::ConstKind::Param(ref pc),
                        ..
                    }) => {
                        !impl_generics.const_param(pc, self).pure_wrt_drop
                    }
                    GenericArgKind::Lifetime(_) |
                    GenericArgKind::Type(_) |
                    GenericArgKind::Const(_) => {
                        // Not a type, const or region param: this should be reported
                        // as an error.
                        false
                    }
                }
            })
            .map(|(&item_param, _)| item_param)
            .collect();
        debug!("destructor_constraint({:?}) = {:?}", def.did, result);
        result
    }
/// Returns the set of types that are required to be alive in
/// order to run the destructor of `def` (see RFCs 769 and
/// 1238).
///
/// Note that this returns only the constraints for the
/// destructor of `def` itself. For the destructors of the
/// contents, you need `adt_dtorck_constraint`.
Returns the set of types that are required to be alive in
order to run the destructor of `def` (see RFCs 769 and
1238).

Note that this returns only the constraints for the
destructor of `def` itself. For the destructors of the
contents, you need `adt_dtorck_constraint`.
Returns the set of types that are required to be alive in order to run the destructor of ` def ` ( see RFCs 769 and 1238 ) . Note that this returns only the constraints for the destructor of ` def ` itself . For the destructors of the contents you need ` adt_dtorck_constraint ` .
pub fn destructor_constraints(self, def: &'tcx ty::AdtDef)
                                  -> Vec<ty::subst::GenericArg<'tcx>>
    {
        let dtor = match def.destructor(self) {
            None => {
                debug!("destructor_constraints({:?}) - no dtor", def.did);
                return vec![]
            }
            Some(dtor) => dtor.did
        };
        let impl_def_id = self.associated_item(dtor).container.id();
        let impl_generics = self.generics_of(impl_def_id);
        // We have a destructor - all the parameters that are not
        // pure_wrt_drop (i.e, don't have a #[may_dangle] attribute)
        // must be live.
        // We need to return the list of parameters from the ADTs
        // generics/substs that correspond to impure parameters on the
        // impl's generics. This is a bit ugly, but conceptually simple:
        //
        // Suppose our ADT looks like the following
        //
        //     struct S<X, Y, Z>(X, Y, Z);
        //
        // and the impl is
        //
        //     impl<#[may_dangle] P0, P1, P2> Drop for S<P1, P2, P0>
        //
        // We want to return the parameters (X, Y). For that, we match
        // up the item-substs <X, Y, Z> with the substs on the impl ADT,
        // <P1, P2, P0>, and then look up which of the impl substs refer to
        // parameters marked as pure.
        let impl_substs = match self.type_of(impl_def_id).kind {
            ty::Adt(def_, substs) if def_ == def => substs,
            _ => bug!()
        };
        let item_substs = match self.type_of(def.did).kind {
            ty::Adt(def_, substs) if def_ == def => substs,
            _ => bug!()
        };
        let result = item_substs.iter().zip(impl_substs.iter())
            .filter(|&(_, &k)| {
                match k.unpack() {
                    GenericArgKind::Lifetime(&ty::RegionKind::ReEarlyBound(ref ebr)) => {
                        !impl_generics.region_param(ebr, self).pure_wrt_drop
                    }
                    GenericArgKind::Type(&ty::TyS {
                        kind: ty::Param(ref pt), ..
                    }) => {
                        !impl_generics.type_param(pt, self).pure_wrt_drop
                    }
                    GenericArgKind::Const(&ty::Const {
                        val: ty::ConstKind::Param(ref pc),
                        ..
                    }) => {
                        !impl_generics.const_param(pc, self).pure_wrt_drop
                    }
                    GenericArgKind::Lifetime(_) |
                    GenericArgKind::Type(_) |
                    GenericArgKind::Const(_) => {
                        // Not a type, const or region param: this should be reported
                        // as an error.
                        false
                    }
                }
            })
            .map(|(&item_param, _)| item_param)
            .collect();
        debug!("destructor_constraint({:?}) = {:?}", def.did, result);
        result
    }
pub fn destructor_constraints ( self , def : & ' tcx ty :: AdtDef ) -> Vec < ty :: subst :: GenericArg < ' tcx > > { let dtor = match def . destructor ( self ) { None => { debug ! ( " " def did ) ; return vec ! [ ] } Some ( dtor ) => dtor . did } ; let impl_def_id = self . associated_item ( dtor ) . container . id ( ) ; let impl_generics = self . generics_of ( impl_def_id ) ; // We have a destructor - all the parameters that are not // pure_wrt_drop (i.e, don't have a #[may_dangle] attribute) // must be live. // We need to return the list of parameters from the ADTs // generics/substs that correspond to impure parameters on the // impl's generics. This is a bit ugly, but conceptually simple: // // Suppose our ADT looks like the following // //     struct S<X, Y, Z>(X, Y, Z); // // and the impl is // //     impl<#[may_dangle] P0, P1, P2> Drop for S<P1, P2, P0> // // We want to return the parameters (X, Y). For that, we match // up the item-substs <X, Y, Z> with the substs on the impl ADT, // <P1, P2, P0>, and then look up which of the impl substs refer to // parameters marked as pure. let impl_substs = match self . type_of ( impl_def_id ) . kind { ty :: Adt ( def_ , substs ) if def_ == def => substs , _ => bug ! ( ) } ; let item_substs = match self . type_of ( def . did ) . kind { ty :: Adt ( def_ , substs ) if def_ == def => substs , _ => bug ! ( ) } ; let result = item_substs . iter ( ) . zip ( impl_substs . iter ( ) ) . filter ( | & ( _ , & k ) | { match k . unpack ( ) { GenericArgKind :: Lifetime ( & ty :: RegionKind :: ReEarlyBound ( ref ebr ) ) => { ! impl_generics . region_param ( ebr , self ) . pure_wrt_drop } GenericArgKind :: Type ( & ty :: TyS { kind : ty :: Param ( ref pt ) , .. } ) => { ! impl_generics . type_param ( pt , self ) . pure_wrt_drop } GenericArgKind :: Const ( & ty :: Const { val : ty :: ConstKind :: Param ( ref pc ) , .. } ) => { ! impl_generics . const_param ( pc , self ) . pure_wrt_drop } GenericArgKind :: Lifetime ( _ ) | GenericArgKind :: Type ( _ ) | GenericArgKind :: Const ( _ ) => { // Not a type, const or region param: this should be reported // as an error. false } } } ) . map ( | ( & item_param , _ ) | item_param ) . collect ( ) ; debug ! ( " " def did result ) ; result }
Returns the set of types that are required to be alive in
order to run the destructor of `def` (see RFCs 769 and
1238).
Returns the set of types that are required to be alive in order to run the destructor of ` def ` ( see RFCs 769 and 1238 ) .
self
def
&'tcx ty::AdtDef