about summary refs log tree commit diff
path: root/tests/ui/did_you_mean/casting-fn-item-to-fn-pointer.stderr
blob: d069d39514dcd0e3ad8a7a8d37403b9c13d8d735 (plain)
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
error[E0277]: a value of type `Vec<(&str, fn())>` cannot be built from an iterator over elements of type `(&str, fn() {foo})`
  --> $DIR/casting-fn-item-to-fn-pointer.rs:6:59
   |
LL |     let _: Vec<(&str, fn())> = [("foo", foo)].into_iter().collect();
   |                                                           ^^^^^^^ value of type `Vec<(&str, fn())>` cannot be built from `std::iter::Iterator<Item=(&str, fn() {foo})>`
   |
   = help: the trait `FromIterator<(&_, fn() {foo})>` is not implemented for `Vec<(&str, fn())>`
           but trait `FromIterator<(&_, fn())>` is implemented for it
   = help: for that trait implementation, expected `fn()`, found `fn() {foo}`
   = note: fn items are distinct from fn pointers
   = help: consider casting the fn item to a fn pointer: `foo as fn()`
note: the method call chain might not have had the expected associated types
  --> $DIR/casting-fn-item-to-fn-pointer.rs:6:47
   |
LL |     let _: Vec<(&str, fn())> = [("foo", foo)].into_iter().collect();
   |                                -------------- ^^^^^^^^^^^ `Iterator::Item` is `(&str, fn() {foo})` here
   |                                |
   |                                this expression has type `[(&str, fn() {foo}); 1]`
note: required by a bound in `collect`
  --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL

error[E0277]: a value of type `Vec<fn()>` cannot be built from an iterator over elements of type `fn() {foo}`
  --> $DIR/casting-fn-item-to-fn-pointer.rs:7:42
   |
LL |     let _: Vec<fn()> = [foo].into_iter().collect();
   |                                          ^^^^^^^ value of type `Vec<fn()>` cannot be built from `std::iter::Iterator<Item=fn() {foo}>`
   |
   = help: the trait `FromIterator<fn() {foo}>` is not implemented for `Vec<fn()>`
           but trait `FromIterator<fn()>` is implemented for it
   = help: for that trait implementation, expected `fn()`, found `fn() {foo}`
   = note: fn items are distinct from fn pointers
   = help: consider casting the fn item to a fn pointer: `foo as fn()`
note: the method call chain might not have had the expected associated types
  --> $DIR/casting-fn-item-to-fn-pointer.rs:7:30
   |
LL |     let _: Vec<fn()> = [foo].into_iter().collect();
   |                        ----- ^^^^^^^^^^^ `Iterator::Item` is `fn() {foo}` here
   |                        |
   |                        this expression has type `[fn() {foo}; 1]`
note: required by a bound in `collect`
  --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL

error[E0308]: mismatched types
  --> $DIR/casting-fn-item-to-fn-pointer.rs:8:24
   |
LL |     let _: Vec<fn()> = Vec::from([foo]);
   |            ---------   ^^^^^^^^^^^^^^^^ expected `Vec<fn()>`, found `Vec<fn() {foo}>`
   |            |
   |            expected due to this
   |
   = note: expected struct `Vec<fn()>`
              found struct `Vec<fn() {foo}>`
   = note: fn items are distinct from fn pointers
   = help: consider casting the fn item to a fn pointer: `foo as fn()`

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.