diff options
| author | ouz-a <oguz.agcayazi@gmail.com> | 2022-08-19 17:08:59 +0300 |
|---|---|---|
| committer | ouz-a <oguz.agcayazi@gmail.com> | 2022-08-19 17:31:57 +0300 |
| commit | c198a20f7c2cb96842a705e770ea0b9dc35b9be0 (patch) | |
| tree | 96b1350bb1be9b8e8958bcbd4b00557567583554 /compiler/rustc_trait_selection/src/traits | |
| parent | 6c943bad02626dddc5e5135b23c77429b6e4a063 (diff) | |
| download | rust-c198a20f7c2cb96842a705e770ea0b9dc35b9be0.tar.gz rust-c198a20f7c2cb96842a705e770ea0b9dc35b9be0.zip | |
Catch overflow early
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/project.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 715b9749268..aeaccffd5f5 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -554,6 +554,18 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> { .flatten() .unwrap_or_else(|| ty::Term::Ty(ty.super_fold_with(self))) }; + // For cases like #95134 we would like to catch overflows early + // otherwise they slip away away and cause ICE. + let recursion_limit = self.tcx().recursion_limit(); + if !recursion_limit.value_within_limit(self.depth) { + let obligation = Obligation::with_depth( + self.cause.clone(), + recursion_limit.0, + self.param_env, + ty, + ); + self.selcx.infcx().report_overflow_error(&obligation, true); + } debug!( ?self.depth, ?ty, |
