@@ -306,9 +306,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
306306 hir:: ItemKind :: Static ( ty, ..) => {
307307 check_item_type ( tcx, def_id, ty. span , UnsizedHandling :: Forbid )
308308 }
309- hir:: ItemKind :: Const ( ty, ..) => {
310- check_item_type ( tcx, def_id, ty. span , UnsizedHandling :: Forbid )
311- }
309+ hir:: ItemKind :: Const ( ty, ..) => check_const_item ( tcx, def_id, ty. span , item. span ) ,
312310 hir:: ItemKind :: Struct ( _, hir_generics) => {
313311 let res = check_type_defn ( tcx, item, false ) ;
314312 check_variances_for_type_defn ( tcx, item, hir_generics) ;
@@ -1280,6 +1278,7 @@ enum UnsizedHandling {
12801278 AllowIfForeignTail ,
12811279}
12821280
1281+ // FIXME(fmease): Rename to check_static_item once LTAs don't use it anymore (#136432)
12831282fn check_item_type (
12841283 tcx : TyCtxt < ' _ > ,
12851284 item_id : LocalDefId ,
@@ -1338,6 +1337,34 @@ fn check_item_type(
13381337 } )
13391338}
13401339
1340+ fn check_const_item (
1341+ tcx : TyCtxt < ' _ > ,
1342+ def_id : LocalDefId ,
1343+ ty_span : Span ,
1344+ item_span : Span ,
1345+ ) -> Result < ( ) , ErrorGuaranteed > {
1346+ enter_wf_checking_ctxt ( tcx, ty_span, def_id, |wfcx| {
1347+ let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
1348+ let ty = wfcx. normalize ( ty_span, Some ( WellFormedLoc :: Ty ( def_id) ) , ty) ;
1349+
1350+ wfcx. register_wf_obligation ( ty_span, Some ( WellFormedLoc :: Ty ( def_id) ) , ty. into ( ) ) ;
1351+ wfcx. register_bound (
1352+ traits:: ObligationCause :: new (
1353+ ty_span,
1354+ wfcx. body_def_id ,
1355+ ObligationCauseCode :: WellFormed ( None ) ,
1356+ ) ,
1357+ wfcx. param_env ,
1358+ ty,
1359+ tcx. require_lang_item ( LangItem :: Sized , None ) ,
1360+ ) ;
1361+
1362+ check_where_clauses ( wfcx, item_span, def_id) ;
1363+
1364+ Ok ( ( ) )
1365+ } )
1366+ }
1367+
13411368#[ instrument( level = "debug" , skip( tcx, hir_self_ty, hir_trait_ref) ) ]
13421369fn check_impl < ' tcx > (
13431370 tcx : TyCtxt < ' tcx > ,
0 commit comments