Skip to content

Commit 5d05876

Browse files
committed
Auto merge of rust-lang#126024 - oli-obk:candidate_key_caching_is_unsound_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)
2 parents 8bfcae7 + 221ae5e commit 5d05876

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
14981498
return false;
14991499
}
15001500

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

1512+
// Avoid using the global cache when we're defining opaque types
1513+
// as their hidden type may impact the result of candidate selection.
1514+
if !self.infcx.defining_opaque_types().is_empty() {
1515+
return false;
1516+
}
1517+
15121518
// Otherwise, we can use the global cache.
15131519
true
15141520
}

src/ci/docker/host-x86_64/x86_64-fuchsia/build-fuchsia.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ KEEP_CHECKOUT=
2929
# Gerrit changes from https://fxrev.dev during development (click the "Download"
3030
# button on a changelist to see the cherry pick ref). Example:
3131
# PICK_REFS=(refs/changes/71/1054071/2 refs/changes/74/1054574/2)
32-
PICK_REFS=()
32+
PICK_REFS=(refs/changes/93/1082793/1 refs/changes/92/1087892/1)
3333

3434
# The commit hash of Fuchsia's integration.git to check out. This controls the
3535
# commit hash of fuchsia.git and some other repos in the "monorepo" checkout, in

tests/crashes/119272.rs tests/ui/auto-traits/opaque_type_candidate_selection.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
//@ known-bug: #119272
1+
//! used to ICE: #119272
2+
3+
//@ check-pass
4+
25
#![feature(type_alias_impl_trait)]
36
mod defining_scope {
47
use super::*;

0 commit comments

Comments
 (0)