]> git.lizzy.rs Git - rust.git/blob - src/test/ui/traits/issue-90662-projection-caching.rs
:arrow_up: rust-analyzer
[rust.git] / src / test / ui / traits / issue-90662-projection-caching.rs
1 // check-pass
2
3 // Regression test for issue #90662
4 // Tests that projection caching does not cause a spurious error
5
6 trait HasProvider<T: ?Sized> {}
7 trait Provider<M> {
8     type Interface: ?Sized;
9 }
10
11 trait Repository {}
12 trait Service {}
13
14 struct DbConnection;
15 impl<M> Provider<M> for DbConnection {
16     type Interface = DbConnection;
17 }
18
19 struct RepositoryImpl;
20 impl<M: HasProvider<DbConnection>> Provider<M> for RepositoryImpl {
21     type Interface = dyn Repository;
22 }
23
24 struct ServiceImpl;
25 impl<M: HasProvider<dyn Repository>> Provider<M> for ServiceImpl {
26     type Interface = dyn Service;
27 }
28
29 struct TestModule;
30 impl HasProvider<<DbConnection as Provider<Self>>::Interface> for TestModule {}
31 impl HasProvider<<RepositoryImpl as Provider<Self>>::Interface> for TestModule {}
32 impl HasProvider<<ServiceImpl as Provider<Self>>::Interface> for TestModule {}
33
34 fn main() {}