diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-11-23 20:32:35 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-23 20:32:35 +0530 |
| commit | bd91c94a5d744e0f93aff073bdbb69d0f4e8d9f6 (patch) | |
| tree | 7796e86984ee33de8899878a240592e49a22fe15 /compiler/rustc_trait_selection/src/traits | |
| parent | 4e0d0d757e2f1b61ec809420b006545a9f8974c0 (diff) | |
| parent | 9decfff6f87d3e5760fd61375c3d27fa45a83e52 (diff) | |
Rollup merge of #104269 - compiler-errors:hang-in-where-clause-sugg, r=lcnr
Fix hang in where-clause suggestion with `predicate_can_apply` Using `predicate_may_hold` during error reporting causes an evaluation overflow, which (because we use `evaluate_obligation_no_overflow`) then causes the predicate to need to be re-evaluated locally, which results in a hang. ... but since the "add a where clause" suggestion is best-effort, just throw any overflow errors. No need for 100% accuracy. r? `@lcnr` who has been thinking about overflows... Let me know if you want more context about this issue, and as always, feel free to reassign. Fixes #104225
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index ef3d300020a..f9f80f9d58c 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -2546,7 +2546,10 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { let obligation = Obligation::new(self.tcx, ObligationCause::dummy(), param_env, cleaned_pred); - self.predicate_may_hold(&obligation) + // We don't use `InferCtxt::predicate_may_hold` because that + // will re-run predicates that overflow locally, which ends up + // taking a really long time to compute. + self.evaluate_obligation(&obligation).map_or(false, |eval| eval.may_apply()) }) } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 186109e7075..bb6d7d0e8df 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -1340,9 +1340,8 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { obligation.param_env, trait_pred_and_suggested_ty, ); - let suggested_ty_would_satisfy_obligation = self - .evaluate_obligation_no_overflow(&new_obligation) - .must_apply_modulo_regions(); + let suggested_ty_would_satisfy_obligation = + self.predicate_must_hold_modulo_regions(&new_obligation); if suggested_ty_would_satisfy_obligation { let sp = self .tcx |
