@@ -307,7 +307,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
307
307
check_item_type ( tcx, def_id, ty. span , UnsizedHandling :: Forbid )
308
308
}
309
309
hir:: ItemKind :: Const ( ty, ..) => {
310
- check_item_type ( tcx, def_id, ty. span , UnsizedHandling :: Forbid )
310
+ check_const_item ( tcx, def_id, ty. span , item . span )
311
311
}
312
312
hir:: ItemKind :: Struct ( _, hir_generics) => {
313
313
let res = check_type_defn ( tcx, item, false ) ;
@@ -1280,6 +1280,7 @@ enum UnsizedHandling {
1280
1280
AllowIfForeignTail ,
1281
1281
}
1282
1282
1283
+ // FIXME(fmease): Rename to check_static_item once LTAs don't use it anymore (#136432)
1283
1284
fn check_item_type (
1284
1285
tcx : TyCtxt < ' _ > ,
1285
1286
item_id : LocalDefId ,
@@ -1338,6 +1339,34 @@ fn check_item_type(
1338
1339
} )
1339
1340
}
1340
1341
1342
+ fn check_const_item (
1343
+ tcx : TyCtxt < ' _ > ,
1344
+ def_id : LocalDefId ,
1345
+ ty_span : Span ,
1346
+ item_span : Span ,
1347
+ ) -> Result < ( ) , ErrorGuaranteed > {
1348
+ enter_wf_checking_ctxt ( tcx, ty_span, def_id, |wfcx| {
1349
+ let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
1350
+ let ty = wfcx. normalize ( ty_span, Some ( WellFormedLoc :: Ty ( def_id) ) , ty) ;
1351
+
1352
+ wfcx. register_wf_obligation ( ty_span, Some ( WellFormedLoc :: Ty ( def_id) ) , ty. into ( ) ) ;
1353
+ wfcx. register_bound (
1354
+ traits:: ObligationCause :: new (
1355
+ ty_span,
1356
+ wfcx. body_def_id ,
1357
+ ObligationCauseCode :: WellFormed ( None ) ,
1358
+ ) ,
1359
+ wfcx. param_env ,
1360
+ ty,
1361
+ tcx. require_lang_item ( LangItem :: Sized , None ) ,
1362
+ ) ;
1363
+
1364
+ check_where_clauses ( wfcx, item_span, def_id) ;
1365
+
1366
+ Ok ( ( ) )
1367
+ } )
1368
+ }
1369
+
1341
1370
#[ instrument( level = "debug" , skip( tcx, hir_self_ty, hir_trait_ref) ) ]
1342
1371
fn check_impl < ' tcx > (
1343
1372
tcx : TyCtxt < ' tcx > ,
0 commit comments