@@ -118,12 +118,17 @@ pub fn check_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: Def
118118 hir:: ItemKind :: Fn ( ..) => {
119119 check_item_fn ( tcx, item) ;
120120 }
121- hir:: ItemKind :: Static ( ..) => {
122- check_item_type ( tcx, item) ;
121+ hir:: ItemKind :: Static ( ref ty , ..) => {
122+ check_item_type ( tcx, item. id , ty . span ) ;
123123 }
124- hir:: ItemKind :: Const ( ..) => {
125- check_item_type ( tcx, item) ;
124+ hir:: ItemKind :: Const ( ref ty , ..) => {
125+ check_item_type ( tcx, item. id , ty . span ) ;
126126 }
127+ hir:: ItemKind :: ForeignMod ( ref module) => for it in module. items . iter ( ) {
128+ if let hir:: ForeignItemKind :: Static ( ref ty, ..) = it. node {
129+ check_item_type ( tcx, it. id , ty. span ) ;
130+ }
131+ } ,
127132 hir:: ItemKind :: Struct ( ref struct_def, ref ast_generics) => {
128133 check_type_defn ( tcx, item, false , |fcx| {
129134 vec ! [ fcx. non_enum_variant( struct_def) ]
@@ -335,14 +340,23 @@ fn check_item_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &hir::Item) {
335340 } )
336341}
337342
338- fn check_item_type < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , item : & hir:: Item ) {
339- debug ! ( "check_item_type: {:?}" , item) ;
340-
341- for_item ( tcx, item) . with_fcx ( |fcx, _this| {
342- let ty = fcx. tcx . type_of ( fcx. tcx . hir . local_def_id ( item. id ) ) ;
343- let item_ty = fcx. normalize_associated_types_in ( item. span , & ty) ;
344-
345- fcx. register_wf_obligation ( item_ty, item. span , ObligationCauseCode :: MiscObligation ) ;
343+ fn check_item_type < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , item_id : ast:: NodeId , ty_span : Span ) {
344+ debug ! ( "check_item_type: {:?}" , item_id) ;
345+
346+ for_id ( tcx, item_id, ty_span) . with_fcx ( |fcx, _this| {
347+ let ty = fcx. tcx . type_of ( fcx. tcx . hir . local_def_id ( item_id) ) ;
348+ let item_ty = fcx. normalize_associated_types_in ( ty_span, & ty) ;
349+
350+ fcx. register_wf_obligation ( item_ty, ty_span, ObligationCauseCode :: MiscObligation ) ;
351+ fcx. register_bound (
352+ item_ty,
353+ fcx. tcx . require_lang_item ( lang_items:: SizedTraitLangItem ) ,
354+ traits:: ObligationCause :: new (
355+ ty_span,
356+ fcx. body_id ,
357+ traits:: MiscObligation ,
358+ ) ,
359+ ) ;
346360
347361 vec ! [ ] // no implied bounds in a const etc
348362 } ) ;
0 commit comments