1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
struct Point<T> {
x: T,
y: T,
}
type PointF = Point<f32>;
struct Pair<T,U> {
x: T,
y: U,
}
type PairF<U> = Pair<f32,U>;
fn main() {
let pt = PointF {
x: 1,
//~^ ERROR mismatched types
//~| expected `f32`, found integer
y: 2,
//~^ ERROR mismatched types
//~| expected `f32`, found integer
};
let pt2 = Point::<f32> {
x: 3,
//~^ ERROR mismatched types
//~| expected `f32`, found integer
y: 4,
//~^ ERROR mismatched types
//~| expected `f32`, found integer
};
let pair = PairF {
x: 5,
//~^ ERROR mismatched types
//~| expected `f32`, found integer
y: 6,
};
let pair2 = PairF::<i32> {
x: 7,
//~^ ERROR mismatched types
//~| expected `f32`, found integer
y: 8,
};
let pt3 = PointF::<i32> { //~ ERROR this type alias takes 0 generic arguments but 1 generic argument
x: 9, //~ ERROR mismatched types
y: 10, //~ ERROR mismatched types
};
match (Point { x: 1, y: 2 }) {
PointF::<u32> { .. } => {} //~ ERROR this type alias takes 0 generic arguments but 1 generic argument
//~^ ERROR mismatched types
}
match (Point { x: 1, y: 2 }) {
PointF { .. } => {} //~ ERROR mismatched types
}
match (Point { x: 1.0, y: 2.0 }) {
PointF { .. } => {} // ok
}
match (Pair { x: 1, y: 2 }) {
PairF::<u32> { .. } => {} //~ ERROR mismatched types
}
match (Pair { x: 1.0, y: 2 }) {
PairF::<u32> { .. } => {} // ok
}
}
|