Add test for DynMap type inference

This commit is contained in:
Florian Diebold 2022-03-13 16:25:03 +01:00
parent 631b504991
commit 1b71cd074d

View File

@ -3609,3 +3609,40 @@ fn f<F: Foo>() {
"#]],
);
}
#[test]
fn dyn_map() {
check_types(
r#"
pub struct Key<K, V, P = (K, V)> {}
pub trait Policy {
type K;
type V;
}
impl<K, V> Policy for (K, V) {
type K = K;
type V = V;
}
pub struct KeyMap<KEY> {}
impl<P: Policy> KeyMap<Key<P::K, P::V, P>> {
pub fn get(&self, key: &P::K) -> P::V {
loop {}
}
}
struct Fn {}
struct FunctionId {}
fn test() {
let key_map: &KeyMap<Key<Fn, FunctionId>> = loop {};
let key;
let result = key_map.get(key);
//^^^^^^ FunctionId
}
"#,
)
}