Skip to content

Commit

Permalink
Auto merge of rust-lang#133626 - lcnr:fix-diesel, r=BoxyUwU
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Dec 2, 2024
2 parents 3bff51e + de94536 commit 32eea2f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1543,14 +1543,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {

if self.can_use_global_caches(param_env, cache_fresh_trait_pred) {
if let Some(res) = tcx.selection_cache.get(&(infcx.typing_env(param_env), pred), tcx) {
Some(res)
} else {
debug_assert_eq!(infcx.selection_cache.get(&(param_env, pred), tcx), None);
None
return Some(res);
} else if cfg!(debug_assertions) {
match infcx.selection_cache.get(&(param_env, pred), tcx) {
None | Some(Err(Overflow(OverflowError::Canonical))) => {}
res => bug!("unexpected local cache result: {res:?}"),
}
}
} else {
infcx.selection_cache.get(&(param_env, pred), tcx)
}

// Subtle: we need to check the local cache even if we're able to use the
// global cache as we don't cache overflow in the global cache but need to
// cache it as otherwise rustdoc hangs when compiling diesel.
infcx.selection_cache.get(&(param_env, pred), tcx)
}

/// Determines whether can we safely cache the result
Expand Down

0 comments on commit 32eea2f

Please sign in to comment.