@@ -429,16 +429,44 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
429
429
// This is because this is not ever a useful obligation to report
430
430
// as the cause of an overflow.
431
431
ty:: PredicateKind :: Clause ( ty:: ClauseKind :: ConstArgHasType ( ct, ty) ) => {
432
- match self . selcx . infcx . at ( & obligation. cause , obligation. param_env ) . eq (
433
- // Only really excercised by generic_const_exprs
434
- DefineOpaqueTypes :: Yes ,
435
- ct. ty ( ) ,
436
- ty,
437
- ) {
438
- Ok ( inf_ok) => ProcessResult :: Changed ( mk_pending ( inf_ok. into_obligations ( ) ) ) ,
439
- Err ( _) => ProcessResult :: Error ( FulfillmentErrorCode :: Select (
440
- SelectionError :: Unimplemented ,
441
- ) ) ,
432
+ // FIXME(BoxyUwU): Really we should not be calling `ct.ty()` for any variant
433
+ // other than `ConstKind::Value`. Unfortunately this would require looking in the
434
+ // env for any `ConstArgHasType` assumptions for parameters and placeholders. I
435
+ // don't really want to implement this in the old solver so I haven't.
436
+ //
437
+ // We do still stall on infer vars though as otherwise a goal like:
438
+ // `ConstArgHasType(?x: usize, usize)` can succeed even though it might later
439
+ // get unified with some const that is not of type `usize`.
440
+ let ( ct, ty) = self . selcx . infcx . resolve_vars_if_possible ( ( ct, ty) ) ;
441
+ match ct. kind ( ) {
442
+ ty:: ConstKind :: Infer ( inf) => {
443
+ pending_obligation. stalled_on . clear ( ) ;
444
+ let inf = match inf {
445
+ ty:: InferConst :: Var ( vid) => TyOrConstInferVar :: Const ( vid) ,
446
+ ty:: InferConst :: EffectVar ( vid) => TyOrConstInferVar :: Effect ( vid) ,
447
+ ty:: InferConst :: Fresh ( _) => {
448
+ bug ! ( "encountered fresh {:?} in fulfill" , ct)
449
+ }
450
+ } ;
451
+ pending_obligation. stalled_on . extend ( [ inf] ) ;
452
+ ProcessResult :: Unchanged
453
+ }
454
+ ty:: ConstKind :: Error ( _) => return ProcessResult :: Changed ( vec ! [ ] ) ,
455
+ _ => {
456
+ match self . selcx . infcx . at ( & obligation. cause , obligation. param_env ) . eq (
457
+ // Only really excercised by generic_const_exprs
458
+ DefineOpaqueTypes :: Yes ,
459
+ ct. ty ( ) ,
460
+ ty,
461
+ ) {
462
+ Ok ( inf_ok) => {
463
+ ProcessResult :: Changed ( mk_pending ( inf_ok. into_obligations ( ) ) )
464
+ }
465
+ Err ( _) => ProcessResult :: Error ( FulfillmentErrorCode :: Select (
466
+ SelectionError :: Unimplemented ,
467
+ ) ) ,
468
+ }
469
+ }
442
470
}
443
471
}
444
472
0 commit comments