]>
Commit | Line | Data |
---|---|---|
b7449926 | 1 | // run-pass |
85aaf69f SL |
2 | // Test that we correctly normalize the type of a struct field |
3 | // which has an associated type. | |
4 | ||
c34b1796 | 5 | |
85aaf69f SL |
6 | pub trait UnifyKey { |
7 | type Value; | |
8 | ||
9 | fn dummy(&self) { } | |
10 | } | |
11 | ||
12 | pub struct Node<K:UnifyKey>(K, K::Value); | |
13 | ||
14 | fn 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 | ||
26 | pub fn main() { | |
27 | let node: Node<i32> = Node(1, Some(22)); | |
c34b1796 | 28 | assert_eq!(foo(&node), Some(22)); |
85aaf69f SL |
29 | |
30 | let node: Node<u32> = Node(1, Some(22)); | |
c34b1796 | 31 | assert_eq!(foo(&node), Some(22)); |
85aaf69f | 32 | } |