diff options
| author | bors <bors@rust-lang.org> | 2024-12-02 15:31:36 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-12-02 15:31:36 +0000 |
| commit | 32eea2f4460b06b12acc98050a4211b8c0ccfd67 (patch) | |
| tree | 9838510bda835d9a8d82226c8b572e72ad3f09a1 | |
| parent | 3bff51ea912d4dfd9caa1e3bc6f68352618208a7 (diff) | |
| parent | de94536553606a3b0c1e461751b0c431c3d642a4 (diff) | |
| download | rust-32eea2f4460b06b12acc98050a4211b8c0ccfd67.tar.gz rust-32eea2f4460b06b12acc98050a4211b8c0ccfd67.zip | |
Auto merge of #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 #133616, didn't test it locally yet as diesel tends to hit an unrelated debug assertion in rustdoc. r? types
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/select/mod.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 50c4f9eff6f..41a35c31fe4 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -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 |
