@@ -429,16 +429,43 @@ 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
+ match ct. kind ( ) {
441
+ ty:: ConstKind :: Infer ( inf) => {
442
+ pending_obligation. stalled_on . clear ( ) ;
443
+ let var = match inf {
444
+ ty:: InferConst :: Var ( vid) => TyOrConstInferVar :: Const ( vid) ,
445
+ ty:: InferConst :: EffectVar ( vid) => TyOrConstInferVar :: Effect ( vid) ,
446
+ ty:: InferConst :: Fresh ( _) => {
447
+ bug ! ( "encountered fresh {:?} in fulfill" , ct)
448
+ }
449
+ } ;
450
+ pending_obligation. stalled_on . extend ( [ var] ) ;
451
+ ProcessResult :: Unchanged
452
+ }
453
+ ty:: ConstKind :: Error ( _) => return ProcessResult :: Changed ( vec ! [ ] ) ,
454
+ _ => {
455
+ match self . selcx . infcx . at ( & obligation. cause , obligation. param_env ) . eq (
456
+ // Only really excercised by generic_const_exprs
457
+ DefineOpaqueTypes :: Yes ,
458
+ ct. ty ( ) ,
459
+ ty,
460
+ ) {
461
+ Ok ( inf_ok) => {
462
+ ProcessResult :: Changed ( mk_pending ( inf_ok. into_obligations ( ) ) )
463
+ }
464
+ Err ( _) => ProcessResult :: Error ( FulfillmentErrorCode :: Select (
465
+ SelectionError :: Unimplemented ,
466
+ ) ) ,
467
+ }
468
+ }
442
469
}
443
470
}
444
471
0 commit comments