Skip to content

Commit 1953a13

Browse files
saethlincuviper
authored andcommitted
Use a reduced recursion limit in the MIR inliner's cycle breaker
(cherry picked from commit 950437a)
1 parent b2a7713 commit 1953a13

File tree

1 file changed

+9
-1
lines changed
  • compiler/rustc_mir_transform/src/inline

1 file changed

+9
-1
lines changed

compiler/rustc_mir_transform/src/inline/cycle.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ pub(crate) fn mir_callgraph_reachable<'tcx>(
137137
}
138138
false
139139
}
140+
// FIXME(-Znext-solver): Remove this hack when trait solver overflow can return an error.
141+
// In code like that pointed out in #128887, the type complexity we ask the solver to deal with
142+
// grows as we recurse into the call graph. If we use the same recursion limit here and in the
143+
// solver, the solver hits the limit first and emits a fatal error. But if we use a reduced
144+
// limit, we will hit the limit first and give up on looking for inlining. And in any case,
145+
// the default recursion limits are quite generous for us. If we need to recurse 64 times
146+
// into the call graph, we're probably not going to find any useful MIR inlining.
147+
let recursion_limit = tcx.recursion_limit() / 2;
140148
process(
141149
tcx,
142150
param_env,
@@ -145,7 +153,7 @@ pub(crate) fn mir_callgraph_reachable<'tcx>(
145153
&mut Vec::new(),
146154
&mut FxHashSet::default(),
147155
&mut FxHashMap::default(),
148-
tcx.recursion_limit(),
156+
recursion_limit,
149157
)
150158
}
151159

0 commit comments

Comments
 (0)