]> git.proxmox.com Git - rustc.git/blob - tests/ui/associated-types/associated-types-struct-field-numbered.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / associated-types / associated-types-struct-field-numbered.rs
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
9 fn dummy(&self) { }
10 }
11
12 pub struct Node<K:UnifyKey>(#[allow(unused_tuple_struct_fields)] 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));
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 }