fn calculate_sized_constraint_inner(&self,
                                        tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                        stack: &mut Vec<DefId>)
                                        -> Ty<'tcx>
    {
        if let Some(ty) = tcx.adt_sized_constraint.borrow().get(&self.did) {
            return ty;
        }

        // Follow the memoization pattern: push the computation of
        // DepNode::SizedConstraint as our current task.
        let _task = tcx.dep_graph.in_task(DepNode::SizedConstraint(self.did));

        if stack.contains(&self.did) {
            debug!("calculate_sized_constraint: {:?} is recursive", self);
            // This should be reported as an error by `check_representable`.
            //
            // Consider the type as Sized in the meanwhile to avoid
            // further errors.
            tcx.adt_sized_constraint.borrow_mut().insert(self.did, tcx.types.err);
            return tcx.types.err;
        }

        stack.push(self.did);

        let tys : Vec<_> =
            self.variants.iter().flat_map(|v| {
                v.fields.last()
            }).flat_map(|f| {
                let ty = tcx.item_type(f.did);
                self.sized_constraint_for_ty(tcx, stack, ty)
            }).collect();

        let self_ = stack.pop().unwrap();
        assert_eq!(self_, self.did);

        let ty = match tys.len() {
            _ if tys.references_error() => tcx.types.err,
            0 => tcx.types.bool,
            1 => tys[0],
            _ => tcx.intern_tup(&tys[..], false)
        };

        let old = tcx.adt_sized_constraint.borrow().get(&self.did).cloned();
        match old {
            Some(old_ty) => {
                debug!("calculate_sized_constraint: {:?} recurred", self);
                assert_eq!(old_ty, tcx.types.err);
                old_ty
            }
            None => {
                debug!("calculate_sized_constraint: {:?} => {:?}", self, ty);
                tcx.adt_sized_constraint.borrow_mut().insert(self.did, ty);
                ty
            }
        }
    }
/// Calculates the Sized-constraint.
///
/// As the Sized-constraint of enums can be a *set* of types,
/// the Sized-constraint may need to be a set also. Because introducing
/// a new type of IVar is currently a complex affair, the Sized-constraint
/// may be a tuple.
///
/// In fact, there are only a few options for the constraint:
///     - `bool`, if the type is always Sized
///     - an obviously-unsized type
///     - a type parameter or projection whose Sizedness can't be known
///     - a tuple of type parameters or projections, if there are multiple
///       such.
///     - a TyError, if a type contained itself. The representability
///       check should catch this case.
Calculates the Sized-constraint.
As the Sized-constraint of enums can be a *set* of types,
the Sized-constraint may need to be a set also. Because introducing
a new type of IVar is currently a complex affair, the Sized-constraint
may be a tuple.

In fact, there are only a few options for the constraint:
`bool`, if the type is always Sized
an obviously-unsized type
a type parameter or projection whose Sizedness can't be known
a tuple of type parameters or projections, if there are multiple
such.
a TyError, if a type contained itself. The representability
check should catch this case.
Calculates the Sized - constraint . As the Sized - constraint of enums can be a * set * of types the Sized - constraint may need to be a set also . Because introducing a new type of IVar is currently a complex affair the Sized - constraint may be a tuple . In fact there are only a few options for the constraint : ` bool ` if the type is always Sized an obviously - unsized type a type parameter or projection whose Sizedness can ' t be known a tuple of type parameters or projections if there are multiple such . a TyError if a type contained itself . The representability check should catch this case .
fn calculate_sized_constraint_inner(&self,
                                        tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                        stack: &mut Vec<DefId>)
                                        -> Ty<'tcx>
    {
        if let Some(ty) = tcx.adt_sized_constraint.borrow().get(&self.did) {
            return ty;
        }
        // Follow the memoization pattern: push the computation of
        // DepNode::SizedConstraint as our current task.
        let _task = tcx.dep_graph.in_task(DepNode::SizedConstraint(self.did));
        if stack.contains(&self.did) {
            debug!("calculate_sized_constraint: {:?} is recursive", self);
            // This should be reported as an error by `check_representable`.
            //
            // Consider the type as Sized in the meanwhile to avoid
            // further errors.
            tcx.adt_sized_constraint.borrow_mut().insert(self.did, tcx.types.err);
            return tcx.types.err;
        }
        stack.push(self.did);
        let tys : Vec<_> =
            self.variants.iter().flat_map(|v| {
                v.fields.last()
            }).flat_map(|f| {
                let ty = tcx.item_type(f.did);
                self.sized_constraint_for_ty(tcx, stack, ty)
            }).collect();
        let self_ = stack.pop().unwrap();
        assert_eq!(self_, self.did);
        let ty = match tys.len() {
            _ if tys.references_error() => tcx.types.err,
            0 => tcx.types.bool,
            1 => tys[0],
            _ => tcx.intern_tup(&tys[..], false)
        };
        let old = tcx.adt_sized_constraint.borrow().get(&self.did).cloned();
        match old {
            Some(old_ty) => {
                debug!("calculate_sized_constraint: {:?} recurred", self);
                assert_eq!(old_ty, tcx.types.err);
                old_ty
            }
            None => {
                debug!("calculate_sized_constraint: {:?} => {:?}", self, ty);
                tcx.adt_sized_constraint.borrow_mut().insert(self.did, ty);
                ty
            }
        }
    }
fn calculate_sized_constraint_inner ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , stack : & mut Vec < DefId > ) -> Ty < ' tcx > { if let Some ( ty ) = tcx . adt_sized_constraint . borrow ( ) . get ( & self . did ) { return ty ; } // Follow the memoization pattern: push the computation of // DepNode::SizedConstraint as our current task. let _task = tcx . dep_graph . in_task ( DepNode :: SizedConstraint ( self . did ) ) ; if stack . contains ( & self . did ) { debug ! ( " " self ) ; // This should be reported as an error by `check_representable`. // // Consider the type as Sized in the meanwhile to avoid // further errors. tcx . adt_sized_constraint . borrow_mut ( ) . insert ( self . did , tcx . types . err ) ; return tcx . types . err ; } stack . push ( self . did ) ; let tys : Vec < _ > = self . variants . iter ( ) . flat_map ( | v | { v . fields . last ( ) } ) . flat_map ( | f | { let ty = tcx . item_type ( f . did ) ; self . sized_constraint_for_ty ( tcx , stack , ty ) } ) . collect ( ) ; let self_ = stack . pop ( ) . unwrap ( ) ; assert_eq ! ( self_ self did ) ; let ty = match tys . len ( ) { _ if tys . references_error ( ) => tcx . types . err , 0 => tcx . types . bool , 1 => tys [ 0 ] , _ => tcx . intern_tup ( & tys [ .. ] , false ) } ; let old = tcx . adt_sized_constraint . borrow ( ) . get ( & self . did ) . cloned ( ) ; match old { Some ( old_ty ) => { debug ! ( " " self ) ; assert_eq ! ( old_ty tcx types err ) ; old_ty } None => { debug ! ( " " self ty ) ; tcx . adt_sized_constraint . borrow_mut ( ) . insert ( self . did , ty ) ; ty } } }
Calculates the Sized-constraint.
Calculates the Sized - constraint .
&self
tcx
TyCtxt<'a, 'tcx, 'tcx>
stack
&mut Vec<DefId>