Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit de94536

Browse files
committed
check local cache even if global is usable
we store overflow errors locally, even if we can otherwise use the global cache for this goal.
1 parent cb2bd2b commit de94536

File tree

1 file changed

+11
-6
lines changed
  • compiler/rustc_trait_selection/src/traits/select

1 file changed

+11
-6
lines changed

compiler/rustc_trait_selection/src/traits/select/mod.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,14 +1537,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
15371537

15381538
if self.can_use_global_caches(param_env, cache_fresh_trait_pred) {
15391539
if let Some(res) = tcx.selection_cache.get(&(infcx.typing_env(param_env), pred), tcx) {
1540-
Some(res)
1541-
} else {
1542-
debug_assert_eq!(infcx.selection_cache.get(&(param_env, pred), tcx), None);
1543-
None
1540+
return Some(res);
1541+
} else if cfg!(debug_assertions) {
1542+
match infcx.selection_cache.get(&(param_env, pred), tcx) {
1543+
None | Some(Err(Overflow(OverflowError::Canonical))) => {}
1544+
res => bug!("unexpected local cache result: {res:?}"),
1545+
}
15441546
}
1545-
} else {
1546-
infcx.selection_cache.get(&(param_env, pred), tcx)
15471547
}
1548+
1549+
// Subtle: we need to check the local cache even if we're able to use the
1550+
// global cache as we don't cache overflow in the global cache but need to
1551+
// cache it as otherwise rustdoc hangs when compiling diesel.
1552+
infcx.selection_cache.get(&(param_env, pred), tcx)
15481553
}
15491554

15501555
/// Determines whether can we safely cache the result

0 commit comments

Comments
 (0)