@@ -439,38 +439,50 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
439439 // This is because this is not ever a useful obligation to report
440440 // as the cause of an overflow.
441441 ty:: PredicateKind :: Clause ( ty:: ClauseKind :: ConstArgHasType ( ct, ty) ) => {
442- // FIXME(BoxyUwU): Really we should not be calling `ct.ty()` for any variant
443- // other than `ConstKind::Value`. Unfortunately this would require looking in the
444- // env for any `ConstArgHasType` assumptions for parameters and placeholders. I
445- // don't really want to implement this in the old solver so I haven't.
446- //
447- // We do still stall on infer vars though as otherwise a goal like:
448- // `ConstArgHasType(?x: usize, usize)` can succeed even though it might later
449- // get unified with some const that is not of type `usize`.
450- let ct = self . selcx . infcx . shallow_resolve_const ( ct) ;
451- match ct. kind ( ) {
452- ty:: ConstKind :: Infer ( ty:: InferConst :: Var ( vid) ) => {
442+ let ct = infcx. shallow_resolve_const ( ct) ;
443+ let ct_ty = match ct. kind ( ) {
444+ ty:: ConstKind :: Infer ( var) => {
445+ let var = match var {
446+ ty:: InferConst :: Var ( vid) => TyOrConstInferVar :: Const ( vid) ,
447+ ty:: InferConst :: EffectVar ( vid) => TyOrConstInferVar :: Effect ( vid) ,
448+ ty:: InferConst :: Fresh ( _) => {
449+ bug ! ( "encountered fresh const in fulfill" )
450+ }
451+ } ;
453452 pending_obligation. stalled_on . clear ( ) ;
454- pending_obligation. stalled_on . extend ( [ TyOrConstInferVar :: Const ( vid ) ] ) ;
455- ProcessResult :: Unchanged
453+ pending_obligation. stalled_on . extend ( [ var ] ) ;
454+ return ProcessResult :: Unchanged ;
456455 }
457456 ty:: ConstKind :: Error ( _) => return ProcessResult :: Changed ( vec ! [ ] ) ,
458- _ => {
459- match self . selcx . infcx . at ( & obligation. cause , obligation. param_env ) . eq (
460- // Only really excercised by generic_const_exprs
461- DefineOpaqueTypes :: Yes ,
462- // THISPR
463- todo ! ( ) ,
464- ty,
465- ) {
466- Ok ( inf_ok) => {
467- ProcessResult :: Changed ( mk_pending ( inf_ok. into_obligations ( ) ) )
468- }
469- Err ( _) => ProcessResult :: Error ( FulfillmentErrorCode :: Select (
470- SelectionError :: Unimplemented ,
471- ) ) ,
472- }
457+ ty:: ConstKind :: Value ( ty, _) => ty,
458+ ty:: ConstKind :: Unevaluated ( uv) => {
459+ infcx. tcx . type_of ( uv. def ) . instantiate ( infcx. tcx , uv. args )
460+ }
461+ // FIXME(generic_const_exprs): we should construct an alias like
462+ // `<lhs_ty as Add<rhs_ty>>::Output` when this is an `Expr` representing
463+ // `lhs + rhs`.
464+ ty:: ConstKind :: Expr ( _) => {
465+ return ProcessResult :: Changed ( mk_pending ( vec ! [ ] ) ) ;
466+ }
467+ ty:: ConstKind :: Placeholder ( _) => {
468+ bug ! ( "placeholder const {:?} in old solver" , ct)
469+ }
470+ ty:: ConstKind :: Bound ( _, _) => bug ! ( "escaping bound vars in {:?}" , ct) ,
471+ ty:: ConstKind :: Param ( param_ct) => {
472+ param_ct. find_ty_from_env ( obligation. param_env )
473473 }
474+ } ;
475+
476+ match infcx. at ( & obligation. cause , obligation. param_env ) . eq (
477+ // Only really excercised by generic_const_exprs
478+ DefineOpaqueTypes :: Yes ,
479+ ct_ty,
480+ ty,
481+ ) {
482+ Ok ( inf_ok) => ProcessResult :: Changed ( mk_pending ( inf_ok. into_obligations ( ) ) ) ,
483+ Err ( _) => ProcessResult :: Error ( FulfillmentErrorCode :: Select (
484+ SelectionError :: ConstArgHasWrongType { ct, ct_ty, expected_ty : ty } ,
485+ ) ) ,
474486 }
475487 }
476488
0 commit comments