|
1 | 1 | use crate::infer::{InferCtxt, TyOrConstInferVar};
|
| 2 | +use crate::traits::error_reporting::TypeErrCtxtExt; |
2 | 3 | use rustc_data_structures::captures::Captures;
|
3 | 4 | use rustc_data_structures::obligation_forest::ProcessResult;
|
4 | 5 | use rustc_data_structures::obligation_forest::{Error, ForestObligation, Outcome};
|
@@ -410,6 +411,29 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
410 | 411 | }
|
411 | 412 | }
|
412 | 413 |
|
| 414 | + ty::PredicateKind::Ambiguous => ProcessResult::Unchanged, |
| 415 | + ty::PredicateKind::AliasRelate(..) => { |
| 416 | + bug!("AliasRelate is only used for new solver") |
| 417 | + } |
| 418 | + |
| 419 | + // General case overflow check. Allow `process_trait_obligation` |
| 420 | + // and `process_projection_obligation` to handle checking for |
| 421 | + // the recursion limit themselves. Also don't check some |
| 422 | + // predicate kinds that don't give further obligations. |
| 423 | + _ if !self |
| 424 | + .selcx |
| 425 | + .tcx() |
| 426 | + .recursion_limit() |
| 427 | + .value_within_limit(obligation.recursion_depth) => |
| 428 | + { |
| 429 | + self.selcx.infcx.err_ctxt().report_overflow_error( |
| 430 | + &obligation.predicate, |
| 431 | + obligation.cause.span, |
| 432 | + false, |
| 433 | + |_| {}, |
| 434 | + ); |
| 435 | + } |
| 436 | + |
413 | 437 | ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg)) => {
|
414 | 438 | match wf::obligations(
|
415 | 439 | self.selcx.infcx,
|
@@ -440,7 +464,12 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
440 | 464 | vec![TyOrConstInferVar::Ty(a), TyOrConstInferVar::Ty(b)];
|
441 | 465 | ProcessResult::Unchanged
|
442 | 466 | }
|
443 |
| - Ok(Ok(ok)) => ProcessResult::Changed(mk_pending(ok.obligations)), |
| 467 | + Ok(Ok(mut ok)) => { |
| 468 | + for subobligation in &mut ok.obligations { |
| 469 | + subobligation.set_depth_from_parent(obligation.recursion_depth); |
| 470 | + } |
| 471 | + ProcessResult::Changed(mk_pending(ok.obligations)) |
| 472 | + } |
444 | 473 | Ok(Err(err)) => {
|
445 | 474 | let expected_found =
|
446 | 475 | ExpectedFound::new(subtype.a_is_expected, subtype.a, subtype.b);
|
@@ -611,10 +640,6 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
611 | 640 | }
|
612 | 641 | }
|
613 | 642 | }
|
614 |
| - ty::PredicateKind::Ambiguous => ProcessResult::Unchanged, |
615 |
| - ty::PredicateKind::AliasRelate(..) => { |
616 |
| - bug!("AliasRelate is only used for new solver") |
617 |
| - } |
618 | 643 | ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
|
619 | 644 | match self.selcx.infcx.at(&obligation.cause, obligation.param_env).eq(
|
620 | 645 | DefineOpaqueTypes::No,
|
|
0 commit comments