fn check_type_defn<F>(&mut self, item: &hir::Item, all_sized: bool, mut lookup_fields: F)
        where F: for<'fcx, 'tcx> FnMut(&FnCtxt<'fcx, 'gcx, 'tcx>) -> Vec<AdtVariant<'tcx>>
    {
        self.for_item(item).with_fcx(|fcx, this| {
            let variants = lookup_fields(fcx);

            for variant in &variants {
                // For DST, all intermediate types must be sized.
                let unsized_len = if all_sized || variant.fields.is_empty() { 0 } else { 1 };
                for field in &variant.fields[..variant.fields.len() - unsized_len] {
                    fcx.register_bound(
                        field.ty,
                        fcx.tcx.require_lang_item(lang_items::SizedTraitLangItem),
                        traits::ObligationCause::new(field.span,
                                                     fcx.body_id,
                                                     traits::FieldSized));
                }

                // All field types must be well-formed.
                for field in &variant.fields {
                    fcx.register_wf_obligation(field.ty, field.span, this.code.clone())
                }
            }

            let def_id = fcx.tcx.hir.local_def_id(item.id);
            let predicates = fcx.tcx.predicates_of(def_id).instantiate_identity(fcx.tcx);
            let predicates = fcx.normalize_associated_types_in(item.span, &predicates);
            this.check_where_clauses(fcx, item.span, &predicates);

            vec![] // no implied bounds in a struct def'n
        });
    }
/// In a type definition, we check that to ensure that the types of the fields are well-formed.
In a type definition, we check that to ensure that the types of the fields are well-formed.
In a type definition we check that to ensure that the types of the fields are well - formed .
fn check_type_defn<F>(&mut self, item: &hir::Item, all_sized: bool, mut lookup_fields: F)
        where F: for<'fcx, 'tcx> FnMut(&FnCtxt<'fcx, 'gcx, 'tcx>) -> Vec<AdtVariant<'tcx>>
    {
        self.for_item(item).with_fcx(|fcx, this| {
            let variants = lookup_fields(fcx);
            for variant in &variants {
                // For DST, all intermediate types must be sized.
                let unsized_len = if all_sized || variant.fields.is_empty() { 0 } else { 1 };
                for field in &variant.fields[..variant.fields.len() - unsized_len] {
                    fcx.register_bound(
                        field.ty,
                        fcx.tcx.require_lang_item(lang_items::SizedTraitLangItem),
                        traits::ObligationCause::new(field.span,
                                                     fcx.body_id,
                                                     traits::FieldSized));
                }
                // All field types must be well-formed.
                for field in &variant.fields {
                    fcx.register_wf_obligation(field.ty, field.span, this.code.clone())
                }
            }
            let def_id = fcx.tcx.hir.local_def_id(item.id);
            let predicates = fcx.tcx.predicates_of(def_id).instantiate_identity(fcx.tcx);
            let predicates = fcx.normalize_associated_types_in(item.span, &predicates);
            this.check_where_clauses(fcx, item.span, &predicates);
            vec![] // no implied bounds in a struct def'n
        });
    }
fn check_type_defn < F > ( & mut self , item : & hir :: Item , all_sized : bool , mut lookup_fields : F ) where F : for < ' fcx , ' tcx > FnMut ( & FnCtxt < ' fcx , ' gcx , ' tcx > ) -> Vec < AdtVariant < ' tcx > > { self . for_item ( item ) . with_fcx ( | fcx , this | { let variants = lookup_fields ( fcx ) ; for variant in & variants { // For DST, all intermediate types must be sized. let unsized_len = if all_sized || variant . fields . is_empty ( ) { 0 } else { 1 } ; for field in & variant . fields [ .. variant . fields . len ( ) - unsized_len ] { fcx . register_bound ( field . ty , fcx . tcx . require_lang_item ( lang_items :: SizedTraitLangItem ) , traits :: ObligationCause :: new ( field . span , fcx . body_id , traits :: FieldSized ) ) ; } // All field types must be well-formed. for field in & variant . fields { fcx . register_wf_obligation ( field . ty , field . span , this . code . clone ( ) ) } } let def_id = fcx . tcx . hir . local_def_id ( item . id ) ; let predicates = fcx . tcx . predicates_of ( def_id ) . instantiate_identity ( fcx . tcx ) ; let predicates = fcx . normalize_associated_types_in ( item . span , & predicates ) ; this . check_where_clauses ( fcx , item . span , & predicates ) ; vec ! [ ] // no implied bounds in a struct def'n } ) ; }
In a type definition, we check that to ensure that the types of the fields are well-formed.
In a type definition we check that to ensure that the types of the fields are well - formed .
&mut self
item
&hir::Item
all_sized
bool
lookup_fields
F
&mut self
item
&hir::Item
all_sized
bool
lookup_fields
F