Don't use global caches if opaques can be defined

This commit is contained in:
Oli Scherer 2024-07-15 09:20:11 +00:00
parent 08a9ca7c18
commit 61b5e11c47
2 changed files with 11 additions and 2 deletions

View File

@ -1498,7 +1498,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
return false; 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 // on the local cache. This effectively disables caching
// during coherence. It is really just a simplification to // during coherence. It is really just a simplification to
// avoid us having to fear that coherence results "pollute" // avoid us having to fear that coherence results "pollute"
@ -1509,6 +1509,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
return false; 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. // Otherwise, we can use the global cache.
true true
} }

View File

@ -1,4 +1,7 @@
//@ known-bug: #119272 //! used to ICE: #119272
//@ check-pass
#![feature(type_alias_impl_trait)] #![feature(type_alias_impl_trait)]
mod defining_scope { mod defining_scope {
use super::*; use super::*;