@@ -268,11 +268,9 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
268
268
check_item_fn ( tcx, def_id, ident, item. span , sig. decl )
269
269
}
270
270
hir:: ItemKind :: Static ( _, ty, ..) => {
271
- check_item_type ( tcx, def_id, ty. span , UnsizedHandling :: Forbid )
272
- }
273
- hir:: ItemKind :: Const ( _, ty, ..) => {
274
- check_item_type ( tcx, def_id, ty. span , UnsizedHandling :: Forbid )
271
+ check_static_item ( tcx, def_id, ty. span , UnsizedHandling :: Forbid )
275
272
}
273
+ hir:: ItemKind :: Const ( _, ty, ..) => check_const_item ( tcx, def_id, ty. span , item. span ) ,
276
274
hir:: ItemKind :: Struct ( _, _, hir_generics) => {
277
275
let res = check_type_defn ( tcx, item, false ) ;
278
276
check_variances_for_type_defn ( tcx, item, hir_generics) ;
@@ -335,7 +333,7 @@ fn check_foreign_item<'tcx>(
335
333
check_item_fn ( tcx, def_id, item. ident , item. span , sig. decl )
336
334
}
337
335
hir:: ForeignItemKind :: Static ( ty, ..) => {
338
- check_item_type ( tcx, def_id, ty. span , UnsizedHandling :: AllowIfForeignTail )
336
+ check_static_item ( tcx, def_id, ty. span , UnsizedHandling :: AllowIfForeignTail )
339
337
}
340
338
hir:: ForeignItemKind :: Type => Ok ( ( ) ) ,
341
339
}
@@ -1300,14 +1298,13 @@ enum UnsizedHandling {
1300
1298
AllowIfForeignTail ,
1301
1299
}
1302
1300
1303
- fn check_item_type (
1301
+ #[ instrument( level = "debug" , skip( tcx, ty_span, unsized_handling) ) ]
1302
+ fn check_static_item (
1304
1303
tcx : TyCtxt < ' _ > ,
1305
1304
item_id : LocalDefId ,
1306
1305
ty_span : Span ,
1307
1306
unsized_handling : UnsizedHandling ,
1308
1307
) -> Result < ( ) , ErrorGuaranteed > {
1309
- debug ! ( "check_item_type: {:?}" , item_id) ;
1310
-
1311
1308
enter_wf_checking_ctxt ( tcx, ty_span, item_id, |wfcx| {
1312
1309
let ty = tcx. type_of ( item_id) . instantiate_identity ( ) ;
1313
1310
let item_ty = wfcx. normalize ( ty_span, Some ( WellFormedLoc :: Ty ( item_id) ) , ty) ;
@@ -1357,6 +1354,34 @@ fn check_item_type(
1357
1354
} )
1358
1355
}
1359
1356
1357
+ fn check_const_item (
1358
+ tcx : TyCtxt < ' _ > ,
1359
+ def_id : LocalDefId ,
1360
+ ty_span : Span ,
1361
+ item_span : Span ,
1362
+ ) -> Result < ( ) , ErrorGuaranteed > {
1363
+ enter_wf_checking_ctxt ( tcx, ty_span, def_id, |wfcx| {
1364
+ let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
1365
+ let ty = wfcx. normalize ( ty_span, Some ( WellFormedLoc :: Ty ( def_id) ) , ty) ;
1366
+
1367
+ wfcx. register_wf_obligation ( ty_span, Some ( WellFormedLoc :: Ty ( def_id) ) , ty. into ( ) ) ;
1368
+ wfcx. register_bound (
1369
+ traits:: ObligationCause :: new (
1370
+ ty_span,
1371
+ wfcx. body_def_id ,
1372
+ ObligationCauseCode :: WellFormed ( None ) ,
1373
+ ) ,
1374
+ wfcx. param_env ,
1375
+ ty,
1376
+ tcx. require_lang_item ( LangItem :: Sized , None ) ,
1377
+ ) ;
1378
+
1379
+ check_where_clauses ( wfcx, item_span, def_id) ;
1380
+
1381
+ Ok ( ( ) )
1382
+ } )
1383
+ }
1384
+
1360
1385
#[ instrument( level = "debug" , skip( tcx, hir_self_ty, hir_trait_ref) ) ]
1361
1386
fn check_impl < ' tcx > (
1362
1387
tcx : TyCtxt < ' tcx > ,
0 commit comments