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