1 // run-pass 2 // Test that we correctly normalize the type of a struct field 3 // which has an associated type. 4 5 6 pub trait UnifyKey { 7 type Value; 8 dummy(&self)9 fn dummy(&self) { } 10 } 11 12 pub struct Node<K:UnifyKey>(K, K::Value); 13 foo<K : UnifyKey<Value=Option<V>>,V : Clone>(node: &Node<K>) -> Option<V>14fn foo<K : UnifyKey<Value=Option<V>>,V : Clone>(node: &Node<K>) -> Option<V> { 15 node.1.clone() 16 } 17 18 impl UnifyKey for i32 { 19 type Value = Option<u32>; 20 } 21 22 impl UnifyKey for u32 { 23 type Value = Option<i32>; 24 } 25 main()26pub fn main() { 27 let node: Node<i32> = Node(1, Some(22)); 28 assert_eq!(foo(&node), Some(22)); 29 30 let node: Node<u32> = Node(1, Some(22)); 31 assert_eq!(foo(&node), Some(22)); 32 } 33