]> git.lizzy.rs Git - rust.git/blob - src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr
Rollup merge of #92802 - compiler-errors:deduplicate-stack-trace, r=oli-obk
[rust.git] / src / test / ui / mismatched_types / closure-arg-type-mismatch.stderr
1 error[E0631]: type mismatch in closure arguments
2   --> $DIR/closure-arg-type-mismatch.rs:3:14
3    |
4 LL |     a.iter().map(|_: (u32, u32)| 45);
5    |              ^^^ ------------------ found signature of `fn((u32, u32)) -> _`
6    |              |
7    |              expected signature of `fn(&(u32, u32)) -> _`
8    |
9 note: required by a bound in `map`
10   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
11    |
12 LL |         F: FnMut(Self::Item) -> B,
13    |            ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map`
14
15 error[E0631]: type mismatch in closure arguments
16   --> $DIR/closure-arg-type-mismatch.rs:4:14
17    |
18 LL |     a.iter().map(|_: &(u16, u16)| 45);
19    |              ^^^ ------------------- found signature of `for<'r> fn(&'r (u16, u16)) -> _`
20    |              |
21    |              expected signature of `fn(&(u32, u32)) -> _`
22    |
23 note: required by a bound in `map`
24   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
25    |
26 LL |         F: FnMut(Self::Item) -> B,
27    |            ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map`
28
29 error[E0631]: type mismatch in closure arguments
30   --> $DIR/closure-arg-type-mismatch.rs:5:14
31    |
32 LL |     a.iter().map(|_: (u16, u16)| 45);
33    |              ^^^ ------------------ found signature of `fn((u16, u16)) -> _`
34    |              |
35    |              expected signature of `fn(&(u32, u32)) -> _`
36    |
37 note: required by a bound in `map`
38   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
39    |
40 LL |         F: FnMut(Self::Item) -> B,
41    |            ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map`
42
43 error[E0308]: mismatched types
44   --> $DIR/closure-arg-type-mismatch.rs:10:5
45    |
46 LL |     baz(f);
47    |     ^^^ lifetime mismatch
48    |
49    = note: expected type `for<'r> Fn<(*mut &'r u32,)>`
50               found type `Fn<(*mut &'a u32,)>`
51 note: the required lifetime does not necessarily outlive the lifetime `'a` as defined here
52   --> $DIR/closure-arg-type-mismatch.rs:9:10
53    |
54 LL | fn _test<'a>(f: fn(*mut &'a u32)) {
55    |          ^^
56 note: the lifetime requirement is introduced here
57   --> $DIR/closure-arg-type-mismatch.rs:8:11
58    |
59 LL | fn baz<F: Fn(*mut &u32)>(_: F) {}
60    |           ^^^^^^^^^^^^^
61
62 error: implementation of `FnOnce` is not general enough
63   --> $DIR/closure-arg-type-mismatch.rs:10:5
64    |
65 LL |     baz(f);
66    |     ^^^ implementation of `FnOnce` is not general enough
67    |
68    = note: `fn(*mut &'a u32)` must implement `FnOnce<(*mut &'0 u32,)>`, for any lifetime `'0`...
69    = note: ...but it actually implements `FnOnce<(*mut &'a u32,)>`
70
71 error[E0308]: mismatched types
72   --> $DIR/closure-arg-type-mismatch.rs:10:5
73    |
74 LL |     baz(f);
75    |     ^^^ lifetime mismatch
76    |
77    = note: expected type `for<'r> Fn<(*mut &'r u32,)>`
78               found type `Fn<(*mut &'a u32,)>`
79 note: the lifetime `'a` as defined here doesn't meet the lifetime requirements
80   --> $DIR/closure-arg-type-mismatch.rs:9:10
81    |
82 LL | fn _test<'a>(f: fn(*mut &'a u32)) {
83    |          ^^
84 note: the lifetime requirement is introduced here
85   --> $DIR/closure-arg-type-mismatch.rs:8:11
86    |
87 LL | fn baz<F: Fn(*mut &u32)>(_: F) {}
88    |           ^^^^^^^^^^^^^
89
90 error: implementation of `FnOnce` is not general enough
91   --> $DIR/closure-arg-type-mismatch.rs:10:5
92    |
93 LL |     baz(f);
94    |     ^^^ implementation of `FnOnce` is not general enough
95    |
96    = note: `fn(*mut &'a u32)` must implement `FnOnce<(*mut &'0 u32,)>`, for any lifetime `'0`...
97    = note: ...but it actually implements `FnOnce<(*mut &'a u32,)>`
98
99 error: aborting due to 7 previous errors
100
101 Some errors have detailed explanations: E0308, E0631.
102 For more information about an error, try `rustc --explain E0308`.