Skip to content

Commit 32eea2f

Browse files
committed
Auto merge of rust-lang#133626 - lcnr:fix-diesel, r=BoxyUwU
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. should fix rust-lang#133616, didn't test it locally yet as diesel tends to hit an unrelated debug assertion in rustdoc. r? types
2 parents 3bff51e + de94536 commit 32eea2f

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

+11-6
Original file line numberDiff line numberDiff line change
@@ -1543,14 +1543,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
15431543

15441544
if self.can_use_global_caches(param_env, cache_fresh_trait_pred) {
15451545
if let Some(res) = tcx.selection_cache.get(&(infcx.typing_env(param_env), pred), tcx) {
1546-
Some(res)
1547-
} else {
1548-
debug_assert_eq!(infcx.selection_cache.get(&(param_env, pred), tcx), None);
1549-
None
1546+
return Some(res);
1547+
} else if cfg!(debug_assertions) {
1548+
match infcx.selection_cache.get(&(param_env, pred), tcx) {
1549+
None | Some(Err(Overflow(OverflowError::Canonical))) => {}
1550+
res => bug!("unexpected local cache result: {res:?}"),
1551+
}
15501552
}
1551-
} else {
1552-
infcx.selection_cache.get(&(param_env, pred), tcx)
15531553
}
1554+
1555+
// Subtle: we need to check the local cache even if we're able to use the
1556+
// global cache as we don't cache overflow in the global cache but need to
1557+
// cache it as otherwise rustdoc hangs when compiling diesel.
1558+
infcx.selection_cache.get(&(param_env, pred), tcx)
15541559
}
15551560

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

0 commit comments

Comments
 (0)