-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a fresh
InferCtxt
when we 'speculatively' evaluate predicates
The existing `InferCtxt` may already have in-progress projections for some of the predicates we may (recursively evaluate). This can cause us to incorrect produce (and cache!) `EvaluatedToRecur`, leading us to incorrectly mark a predicate as unimplemented. We now create a fresh `InferCtxt` for each sub-obligation that we 'speculatively' evaluate. This causes us to miss out on some legitimate caching opportunities, but ensures that our speculative evaluation cannot pollute any of the caches from the 'real' `InferCtxt`. The evaluation can still update *global* caches, but our global caches don't have any notion of 'in progress', so this is fine. Fixes #90662
- Loading branch information
Showing
2 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// check-pass | ||
|
||
// Regression test for issue #90662 | ||
// Tests that projection caching does not cause a spurious error | ||
|
||
trait HasProvider<T: ?Sized> {} | ||
trait Provider<M> { | ||
type Interface: ?Sized; | ||
} | ||
|
||
trait Repository {} | ||
trait Service {} | ||
|
||
struct DbConnection; | ||
impl<M> Provider<M> for DbConnection { | ||
type Interface = DbConnection; | ||
} | ||
|
||
struct RepositoryImpl; | ||
impl<M: HasProvider<DbConnection>> Provider<M> for RepositoryImpl { | ||
type Interface = dyn Repository; | ||
} | ||
|
||
struct ServiceImpl; | ||
impl<M: HasProvider<dyn Repository>> Provider<M> for ServiceImpl { | ||
type Interface = dyn Service; | ||
} | ||
|
||
struct TestModule; | ||
impl HasProvider<<DbConnection as Provider<Self>>::Interface> for TestModule {} | ||
impl HasProvider<<RepositoryImpl as Provider<Self>>::Interface> for TestModule {} | ||
impl HasProvider<<ServiceImpl as Provider<Self>>::Interface> for TestModule {} | ||
|
||
fn main() {} |