]> git.proxmox.com Git - rustc.git/blame - src/test/ui/generic-associated-types/issue-79422.rs
New upstream version 1.52.0~beta.3+dfsg1
[rustc.git] / src / test / ui / generic-associated-types / issue-79422.rs
CommitLineData
5869c6ff
XL
1#![allow(incomplete_features)]
2#![feature(generic_associated_types)]
3
4trait RefCont<'a, T> {
5 fn t(&'a self) -> &'a T;
6}
7
8impl<'a, T> RefCont<'a, T> for &'a T {
9 fn t(&'a self) -> &'a T {
10 self
11 }
12}
13
14impl<'a, T> RefCont<'a, T> for Box<T> {
15 fn t(&'a self) -> &'a T {
16 self.as_ref()
17 }
18}
19
20trait MapLike<K, V> {
21 type VRefCont<'a>: RefCont<'a, V>;
6a06907d 22 //~^ ERROR missing generics
5869c6ff
XL
23 fn get<'a>(&'a self, key: &K) -> Option<Self::VRefCont<'a>>;
24}
25
26impl<K: Ord, V: 'static> MapLike<K, V> for std::collections::BTreeMap<K, V> {
27 type VRefCont<'a> = &'a V;
28 fn get<'a>(&'a self, key: &K) -> Option<&'a V> {
29 std::collections::BTreeMap::get(self, key)
30 }
31}
32
33struct Source;
34
35impl<K, V: Default> MapLike<K, V> for Source {
36 type VRefCont<'a> = Box<V>;
37 fn get<'a>(&self, _: &K) -> Option<Box<V>> {
38 Some(Box::new(V::default()))
39 }
40}
41
42fn main() {
43 let m = Box::new(std::collections::BTreeMap::<u8, u8>::new())
44 as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
6a06907d 45 //~^^ ERROR type mismatch resolving
5869c6ff 46}