about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRémy Rakic <remy.rakic+github@gmail.com>2023-08-29 19:02:24 +0000
committerRémy Rakic <remy.rakic+github@gmail.com>2023-08-29 19:02:24 +0000
commit7762ac7bb5ac10046a5a9ee838480a78bf150237 (patch)
treeb606205d7d4e96e5ce163789b01dc10588a152c3
parentbb90f810703af79f6d4006d455bbb6782838854b (diff)
downloadrust-7762ac7bb5ac10046a5a9ee838480a78bf150237.tar.gz
rust-7762ac7bb5ac10046a5a9ee838480a78bf150237.zip
handle edge-case of a recursion limit of 0
-rw-r--r--compiler/rustc_trait_selection/src/solve/search_graph/mod.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/search_graph/mod.rs b/compiler/rustc_trait_selection/src/solve/search_graph/mod.rs
index 49ebfa4e6cb..ca3c64b428e 100644
--- a/compiler/rustc_trait_selection/src/solve/search_graph/mod.rs
+++ b/compiler/rustc_trait_selection/src/solve/search_graph/mod.rs
@@ -51,9 +51,13 @@ pub(super) struct SearchGraph<'tcx> {
 
 impl<'tcx> SearchGraph<'tcx> {
     pub(super) fn new(tcx: TyCtxt<'tcx>, mode: SolverMode) -> SearchGraph<'tcx> {
+        let local_overflow_limit = {
+            let recursion_limit = tcx.recursion_limit().0;
+            if recursion_limit == 0 { 0 } else { recursion_limit.ilog2() as usize }
+        };
         Self {
             mode,
-            local_overflow_limit: tcx.recursion_limit().0.ilog2() as usize,
+            local_overflow_limit,
             stack: Default::default(),
             provisional_cache: ProvisionalCache::empty(),
         }