@@ -43,42 +43,48 @@ error[E0308]: mismatched types
43
43
--> $DIR/fn-pointer-mismatch.rs:36:29
44
44
|
45
45
LL | let c: fn(u32) -> u32 = &foo;
46
- | -------------- ^^^^
47
- | | |
48
- | | expected fn pointer, found `&fn(u32) -> u32 {foo}`
49
- | | help: consider removing the reference: `foo`
46
+ | -------------- ^^^^ expected fn pointer, found `&fn(u32) -> u32 {foo}`
47
+ | |
50
48
| expected due to this
51
49
|
52
50
= note: expected fn pointer `fn(u32) -> u32`
53
51
found reference `&fn(u32) -> u32 {foo}`
52
+ help: consider removing the reference
53
+ |
54
+ LL | let c: fn(u32) -> u32 = foo;
55
+ | ~~~
54
56
55
57
error[E0308]: mismatched types
56
58
--> $DIR/fn-pointer-mismatch.rs:42:30
57
59
|
58
60
LL | let d: &fn(u32) -> u32 = foo;
59
- | --------------- ^^^
60
- | | |
61
- | | expected `&fn(u32) -> u32`, found fn item
62
- | | help: consider using a reference: `&foo`
61
+ | --------------- ^^^ expected `&fn(u32) -> u32`, found fn item
62
+ | |
63
63
| expected due to this
64
64
|
65
65
= note: expected reference `&fn(u32) -> u32`
66
66
found fn item `fn(u32) -> u32 {foo}`
67
+ help: consider using a reference
68
+ |
69
+ LL | let d: &fn(u32) -> u32 = &foo;
70
+ | ~~~~
67
71
68
72
error[E0308]: mismatched types
69
73
--> $DIR/fn-pointer-mismatch.rs:48:30
70
74
|
71
75
LL | let e: &fn(u32) -> u32 = &foo;
72
- | --------------- ^^^^
73
- | | |
74
- | | expected `&fn(u32) -> u32`, found `&fn(u32) -> u32 {foo}`
75
- | | help: consider casting to a fn pointer: `&(foo as fn(u32) -> u32)`
76
+ | --------------- ^^^^ expected `&fn(u32) -> u32`, found `&fn(u32) -> u32 {foo}`
77
+ | |
76
78
| expected due to this
77
79
|
78
80
= note: expected reference `&fn(u32) -> u32`
79
81
found reference `&fn(u32) -> u32 {foo}`
80
82
= note: fn items are distinct from fn pointers
81
83
= note: when the arguments and return types match, functions can be coerced to function pointers
84
+ help: consider casting to a fn pointer
85
+ |
86
+ LL | let e: &fn(u32) -> u32 = &(foo as fn(u32) -> u32);
87
+ | ~~~~~~~~~~~~~~~~~~~~~~~~
82
88
83
89
error: aborting due to 6 previous errors
84
90
0 commit comments