@@ -1488,6 +1488,39 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
14881488 . then ( || WellFormedLoc :: Ty ( param. def_id . expect_local ( ) ) ) ,
14891489 default,
14901490 ) ;
1491+ } else {
1492+ // If we've got a generic const parameter we still want to check its
1493+ // type is correct in case both it and the param type are fully concrete.
1494+ let GenericArgKind :: Const ( ct) = default. unpack ( ) else {
1495+ continue ;
1496+ } ;
1497+
1498+ let ct_ty = match ct. kind ( ) {
1499+ ty:: ConstKind :: Infer ( _)
1500+ | ty:: ConstKind :: Placeholder ( _)
1501+ | ty:: ConstKind :: Bound ( _, _) => unreachable ! ( ) ,
1502+ ty:: ConstKind :: Error ( _) | ty:: ConstKind :: Expr ( _) => continue ,
1503+ ty:: ConstKind :: Value ( cv) => cv. ty ,
1504+ ty:: ConstKind :: Unevaluated ( uv) => {
1505+ infcx. tcx . type_of ( uv. def ) . instantiate ( infcx. tcx , uv. args )
1506+ }
1507+ ty:: ConstKind :: Param ( param_ct) => param_ct. find_ty_from_env ( wfcx. param_env ) ,
1508+ } ;
1509+
1510+ let param_ty = tcx. type_of ( param. def_id ) . instantiate_identity ( ) ;
1511+ if !ct_ty. has_param ( ) && !param_ty. has_param ( ) {
1512+ let cause = traits:: ObligationCause :: new (
1513+ tcx. def_span ( param. def_id ) ,
1514+ wfcx. body_def_id ,
1515+ ObligationCauseCode :: WellFormed ( None ) ,
1516+ ) ;
1517+ wfcx. register_obligation ( Obligation :: new (
1518+ tcx,
1519+ cause,
1520+ wfcx. param_env ,
1521+ ty:: ClauseKind :: ConstArgHasType ( ct, param_ty) ,
1522+ ) ) ;
1523+ }
14911524 }
14921525 }
14931526 }
0 commit comments