@@ -340,33 +340,31 @@ fn check_item_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &hir::Item) {
340
340
} )
341
341
}
342
342
343
- fn check_item_type < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
344
- item_id : ast:: NodeId ,
345
- ty_span : Span ,
346
- allow_foreign_ty : bool ) {
343
+ fn check_item_type < ' a , ' tcx > (
344
+ tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
345
+ item_id : ast:: NodeId ,
346
+ ty_span : Span ,
347
+ allow_foreign_ty : bool ,
348
+ ) {
347
349
debug ! ( "check_item_type: {:?}" , item_id) ;
348
350
349
351
for_id ( tcx, item_id, ty_span) . with_fcx ( |fcx, _this| {
350
352
let ty = fcx. tcx . type_of ( fcx. tcx . hir . local_def_id ( item_id) ) ;
351
353
let item_ty = fcx. normalize_associated_types_in ( ty_span, & ty) ;
352
354
353
- let mut allow_unsized = false ;
355
+ let mut forbid_unsized = true ;
354
356
if allow_foreign_ty {
355
357
if let TyKind :: Foreign ( _) = tcx. struct_tail ( item_ty) . sty {
356
- allow_unsized = true ;
358
+ forbid_unsized = false ;
357
359
}
358
360
}
359
361
360
- if !allow_unsized {
361
- fcx . register_wf_obligation ( item_ty , ty_span , ObligationCauseCode :: MiscObligation ) ;
362
+ fcx . register_wf_obligation ( item_ty , ty_span , ObligationCauseCode :: MiscObligation ) ;
363
+ if forbid_unsized {
362
364
fcx. register_bound (
363
365
item_ty,
364
366
fcx. tcx . require_lang_item ( lang_items:: SizedTraitLangItem ) ,
365
- traits:: ObligationCause :: new (
366
- ty_span,
367
- fcx. body_id ,
368
- traits:: MiscObligation ,
369
- ) ,
367
+ traits:: ObligationCause :: new ( ty_span, fcx. body_id , traits:: MiscObligation ) ,
370
368
) ;
371
369
}
372
370
0 commit comments