Skip to content

Commit 61b5e11

Browse files
committed
Don't use global caches if opaques can be defined
1 parent 08a9ca7 commit 61b5e11

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
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
}

tests/crashes/119272.rs renamed to 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)