Skip to content

Commit

Permalink
Auto merge of rust-lang#126024 - oli-obk:candidate_key_caching_is_uns…
Browse files Browse the repository at this point in the history
…ound_yay, r=lcnr

Do not use global caches if opaque types can be defined

fixes rust-lang#119272

r? `@lcnr`

This is certainly a crude way to make the cache sound wrt opaque types, but since perf lets us get away with this, let's do it in the old solver and let the new solver fix this correctly once and for all.

cc rust-lang#122192 (comment)
  • Loading branch information
bors committed Jul 23, 2024
2 parents 8bfcae7 + 221ae5e commit 5d05876
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 7 additions & 1 deletion compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
return false;
}

// Avoid using the master cache during coherence and just rely
// Avoid using the global cache during coherence and just rely
// on the local cache. This effectively disables caching
// during coherence. It is really just a simplification to
// avoid us having to fear that coherence results "pollute"
Expand All @@ -1509,6 +1509,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
return false;
}

// Avoid using the global cache when we're defining opaque types
// as their hidden type may impact the result of candidate selection.
if !self.infcx.defining_opaque_types().is_empty() {
return false;
}

// Otherwise, we can use the global cache.
true
}
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/host-x86_64/x86_64-fuchsia/build-fuchsia.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ KEEP_CHECKOUT=
# Gerrit changes from https://fxrev.dev during development (click the "Download"
# button on a changelist to see the cherry pick ref). Example:
# PICK_REFS=(refs/changes/71/1054071/2 refs/changes/74/1054574/2)
PICK_REFS=()
PICK_REFS=(refs/changes/93/1082793/1 refs/changes/92/1087892/1)

# The commit hash of Fuchsia's integration.git to check out. This controls the
# commit hash of fuchsia.git and some other repos in the "monorepo" checkout, in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
//@ known-bug: #119272
//! used to ICE: #119272

//@ check-pass

#![feature(type_alias_impl_trait)]
mod defining_scope {
use super::*;
Expand Down

0 comments on commit 5d05876

Please sign in to comment.