crate fn adt_dtorck_constraint<'a, 'tcx>(
    tcx: TyCtxt<'a, 'tcx, 'tcx>,
    def_id: DefId,
) -> Result<DtorckConstraint<'tcx>, NoSolution> {
    let def = tcx.adt_def(def_id);
    let span = tcx.def_span(def_id);
    debug!("dtorck_constraint: {:?}", def);

    if def.is_phantom_data() {
        // The first generic parameter here is guaranteed to be a type because it's
        // `PhantomData`.
        let substs = Substs::identity_for_item(tcx, def_id);
        assert_eq!(substs.len(), 1);
        let result = DtorckConstraint {
            outlives: vec![],
            dtorck_types: vec![substs.type_at(0)],
            overflows: vec![],
        };
        debug!("dtorck_constraint: {:?} => {:?}", def, result);
        return Ok(result);
    }

    let mut result = def
        .all_fields()
        .map(|field| tcx.type_of(field.did))
        .map(|fty| dtorck_constraint_for_ty(tcx, span, fty, 0, fty))
        .collect::<Result<DtorckConstraint, NoSolution>>()?;
    result.outlives.extend(tcx.destructor_constraints(def));
    dedup_dtorck_constraint(&mut result);

    debug!("dtorck_constraint: {:?} => {:?}", def, result);

    Ok(result)
}
/// Calculates the dtorck constraint for a type.
Calculates the dtorck constraint for a type.
Calculates the dtorck constraint for a type .
crate fn adt_dtorck_constraint<'a, 'tcx>(
    tcx: TyCtxt<'a, 'tcx, 'tcx>,
    def_id: DefId,
) -> Result<DtorckConstraint<'tcx>, NoSolution> {
    let def = tcx.adt_def(def_id);
    let span = tcx.def_span(def_id);
    debug!("dtorck_constraint: {:?}", def);
    if def.is_phantom_data() {
        // The first generic parameter here is guaranteed to be a type because it's
        // `PhantomData`.
        let substs = Substs::identity_for_item(tcx, def_id);
        assert_eq!(substs.len(), 1);
        let result = DtorckConstraint {
            outlives: vec![],
            dtorck_types: vec![substs.type_at(0)],
            overflows: vec![],
        };
        debug!("dtorck_constraint: {:?} => {:?}", def, result);
        return Ok(result);
    }
    let mut result = def
        .all_fields()
        .map(|field| tcx.type_of(field.did))
        .map(|fty| dtorck_constraint_for_ty(tcx, span, fty, 0, fty))
        .collect::<Result<DtorckConstraint, NoSolution>>()?;
    result.outlives.extend(tcx.destructor_constraints(def));
    dedup_dtorck_constraint(&mut result);
    debug!("dtorck_constraint: {:?} => {:?}", def, result);
    Ok(result)
}
crate fn adt_dtorck_constraint < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , def_id : DefId , ) -> Result < DtorckConstraint < ' tcx > , NoSolution > { let def = tcx . adt_def ( def_id ) ; let span = tcx . def_span ( def_id ) ; debug ! ( " " def ) ; if def . is_phantom_data ( ) { // The first generic parameter here is guaranteed to be a type because it's // `PhantomData`. let substs = Substs :: identity_for_item ( tcx , def_id ) ; assert_eq ! ( substs len ( ) 1 ) ; let result = DtorckConstraint { outlives : vec ! [ ] , dtorck_types : vec ! [ substs type_at ( 0 ) ] , overflows : vec ! [ ] , } ; debug ! ( " " def result ) ; return Ok ( result ) ; } let mut result = def . all_fields ( ) . map ( | field | tcx . type_of ( field . did ) ) . map ( | fty | dtorck_constraint_for_ty ( tcx , span , fty , 0 , fty ) ) . collect :: < Result < DtorckConstraint , NoSolution > > ( ) ? ; result . outlives . extend ( tcx . destructor_constraints ( def ) ) ; dedup_dtorck_constraint ( & mut result ) ; debug ! ( " " def result ) ; Ok ( result ) }
Calculates the dtorck constraint for a type.
Calculates the dtorck constraint for a type .
tcx
TyCtxt<'a, 'tcx, 'tcx>
def_id
DefId
tcx
TyCtxt<'a, 'tcx, 'tcx>
def_id
DefId