fn check_item_well_formed(&mut self, item: &hir::Item) {
        let tcx = self.tcx;
        debug!("check_item_well_formed(it.id={}, it.name={})",
               item.id,
               tcx.item_path_str(tcx.hir.local_def_id(item.id)));

        match item.node {
            /// Right now we check that every default trait implementation
            /// has an implementation of itself. Basically, a case like:
            ///
            /// `impl Trait for T {}`
            ///
            /// has a requirement of `T: Trait` which was required for default
            /// method implementations. Although this could be improved now that
            /// there's a better infrastructure in place for this, it's being left
            /// for a follow-up work.
            ///
            /// Since there's such a requirement, we need to check *just* positive
            /// implementations, otherwise things like:
            ///
            /// impl !Send for T {}
            ///
            /// won't be allowed unless there's an *explicit* implementation of `Send`
            /// for `T`
            hir::ItemImpl(_, hir::ImplPolarity::Positive, _, _,
                          ref trait_ref, ref self_ty, _) => {
                self.check_impl(item, self_ty, trait_ref);
            }
            hir::ItemImpl(_, hir::ImplPolarity::Negative, _, _, Some(_), ..) => {
                // FIXME(#27579) what amount of WF checking do we need for neg impls?

                let trait_ref = tcx.impl_trait_ref(tcx.hir.local_def_id(item.id)).unwrap();
                if !tcx.trait_has_default_impl(trait_ref.def_id) {
                    error_192(tcx, item.span);
                }
            }
            hir::ItemFn(..) => {
                self.check_item_fn(item);
            }
            hir::ItemStatic(..) => {
                self.check_item_type(item);
            }
            hir::ItemConst(..) => {
                self.check_item_type(item);
            }
            hir::ItemStruct(ref struct_def, ref ast_generics) => {
                self.check_type_defn(item, false, |fcx| {
                    vec![fcx.struct_variant(struct_def)]
                });

                self.check_variances_for_type_defn(item, ast_generics);
            }
            hir::ItemUnion(ref struct_def, ref ast_generics) => {
                self.check_type_defn(item, true, |fcx| {
                    vec![fcx.struct_variant(struct_def)]
                });

                self.check_variances_for_type_defn(item, ast_generics);
            }
            hir::ItemEnum(ref enum_def, ref ast_generics) => {
                self.check_type_defn(item, true, |fcx| {
                    fcx.enum_variants(enum_def)
                });

                self.check_variances_for_type_defn(item, ast_generics);
            }
            hir::ItemTrait(..) => {
                self.check_trait(item);
            }
            _ => {}
        }
    }
/// Checks that the field types (in a struct def'n) or argument types (in an enum def'n) are
/// well-formed, meaning that they do not require any constraints not declared in the struct
/// definition itself. For example, this definition would be illegal:
///
///     struct Ref<'a, T> { x: &'a T }
///
/// because the type did not declare that `T:'a`.
///
/// We do this check as a pre-pass before checking fn bodies because if these constraints are
/// not included it frequently leads to confusing errors in fn bodies. So it's better to check
/// the types first.
Checks that the field types (in a struct def'n) or argument types (in an enum def'n) are
well-formed, meaning that they do not require any constraints not declared in the struct
definition itself. For example, this definition would be illegal.



because the type did not declare that `T:'a`.

We do this check as a pre-pass before checking fn bodies because if these constraints are
not included it frequently leads to confusing errors in fn bodies. So it's better to check
the types first.
Checks that the field types ( in a struct def ' n ) or argument types ( in an enum def ' n ) are well - formed meaning that they do not require any constraints not declared in the struct definition itself . For example this definition would be illegal . because the type did not declare that ` T : ' a ` . We do this check as a pre - pass before checking fn bodies because if these constraints are not included it frequently leads to confusing errors in fn bodies . So it ' s better to check the types first .
fn check_item_well_formed(&mut self, item: &hir::Item) {
        let tcx = self.tcx;
        debug!("check_item_well_formed(it.id={}, it.name={})",
               item.id,
               tcx.item_path_str(tcx.hir.local_def_id(item.id)));
        match item.node {
            /// Right now we check that every default trait implementation
            /// has an implementation of itself. Basically, a case like:
            ///
            /// `impl Trait for T {}`
            ///
            /// has a requirement of `T: Trait` which was required for default
            /// method implementations. Although this could be improved now that
            /// there's a better infrastructure in place for this, it's being left
            /// for a follow-up work.
            ///
            /// Since there's such a requirement, we need to check *just* positive
            /// implementations, otherwise things like:
            ///
            /// impl !Send for T {}
            ///
            /// won't be allowed unless there's an *explicit* implementation of `Send`
            /// for `T`
            hir::ItemImpl(_, hir::ImplPolarity::Positive, _, _,
                          ref trait_ref, ref self_ty, _) => {
                self.check_impl(item, self_ty, trait_ref);
            }
            hir::ItemImpl(_, hir::ImplPolarity::Negative, _, _, Some(_), ..) => {
                // FIXME(#27579) what amount of WF checking do we need for neg impls?
                let trait_ref = tcx.impl_trait_ref(tcx.hir.local_def_id(item.id)).unwrap();
                if !tcx.trait_has_default_impl(trait_ref.def_id) {
                    error_192(tcx, item.span);
                }
            }
            hir::ItemFn(..) => {
                self.check_item_fn(item);
            }
            hir::ItemStatic(..) => {
                self.check_item_type(item);
            }
            hir::ItemConst(..) => {
                self.check_item_type(item);
            }
            hir::ItemStruct(ref struct_def, ref ast_generics) => {
                self.check_type_defn(item, false, |fcx| {
                    vec![fcx.struct_variant(struct_def)]
                });
                self.check_variances_for_type_defn(item, ast_generics);
            }
            hir::ItemUnion(ref struct_def, ref ast_generics) => {
                self.check_type_defn(item, true, |fcx| {
                    vec![fcx.struct_variant(struct_def)]
                });
                self.check_variances_for_type_defn(item, ast_generics);
            }
            hir::ItemEnum(ref enum_def, ref ast_generics) => {
                self.check_type_defn(item, true, |fcx| {
                    fcx.enum_variants(enum_def)
                });
                self.check_variances_for_type_defn(item, ast_generics);
            }
            hir::ItemTrait(..) => {
                self.check_trait(item);
            }
            _ => {}
        }
    }
fn check_item_well_formed ( & mut self , item : & hir :: Item ) { let tcx = self . tcx ; debug ! ( " " item id tcx item_path_str ( tcx hir local_def_id ( item id ) ) ) ; match item . node { /// Right now we check that every default trait implementation /// has an implementation of itself. Basically, a case like: /// /// `impl Trait for T {}` /// /// has a requirement of `T: Trait` which was required for default /// method implementations. Although this could be improved now that /// there's a better infrastructure in place for this, it's being left /// for a follow-up work. /// /// Since there's such a requirement, we need to check *just* positive /// implementations, otherwise things like: /// /// impl !Send for T {} /// /// won't be allowed unless there's an *explicit* implementation of `Send` /// for `T` hir :: ItemImpl ( _ , hir :: ImplPolarity :: Positive , _ , _ , ref trait_ref , ref self_ty , _ ) => { self . check_impl ( item , self_ty , trait_ref ) ; } hir :: ItemImpl ( _ , hir :: ImplPolarity :: Negative , _ , _ , Some ( _ ) , .. ) => { // FIXME(#27579) what amount of WF checking do we need for neg impls? let trait_ref = tcx . impl_trait_ref ( tcx . hir . local_def_id ( item . id ) ) . unwrap ( ) ; if ! tcx . trait_has_default_impl ( trait_ref . def_id ) { error_192 ( tcx , item . span ) ; } } hir :: ItemFn ( .. ) => { self . check_item_fn ( item ) ; } hir :: ItemStatic ( .. ) => { self . check_item_type ( item ) ; } hir :: ItemConst ( .. ) => { self . check_item_type ( item ) ; } hir :: ItemStruct ( ref struct_def , ref ast_generics ) => { self . check_type_defn ( item , false , | fcx | { vec ! [ fcx struct_variant ( struct_def ) ] } ) ; self . check_variances_for_type_defn ( item , ast_generics ) ; } hir :: ItemUnion ( ref struct_def , ref ast_generics ) => { self . check_type_defn ( item , true , | fcx | { vec ! [ fcx struct_variant ( struct_def ) ] } ) ; self . check_variances_for_type_defn ( item , ast_generics ) ; } hir :: ItemEnum ( ref enum_def , ref ast_generics ) => { self . check_type_defn ( item , true , | fcx | { fcx . enum_variants ( enum_def ) } ) ; self . check_variances_for_type_defn ( item , ast_generics ) ; } hir :: ItemTrait ( .. ) => { self . check_trait ( item ) ; } _ => { } } }
Checks that the field types (in a struct def'n) or argument types (in an enum def'n) are
well-formed, meaning that they do not require any constraints not declared in the struct
definition itself.
Checks that the field types ( in a struct def ' n ) or argument types ( in an enum def ' n ) are well - formed meaning that they do not require any constraints not declared in the struct definition itself .
&mut self
item
&hir::Item
&mut self
item
&hir::Item