]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0059.md
Rollup merge of #68120 - Centril:ban-range-to-dotdotdot, r=oli-obk
[rust.git] / src / librustc_error_codes / error_codes / E0059.md
1 The built-in function traits are generic over a tuple of the function arguments.
2 If one uses angle-bracket notation (`Fn<(T,), Output=U>`) instead of parentheses
3 (`Fn(T) -> U`) to denote the function trait, the type parameter should be a
4 tuple. Otherwise function call notation cannot be used and the trait will not be
5 implemented by closures.
6
7 The most likely source of this error is using angle-bracket notation without
8 wrapping the function argument type into a tuple, for example:
9
10 ```compile_fail,E0059
11 #![feature(unboxed_closures)]
12
13 fn foo<F: Fn<i32>>(f: F) -> F::Output { f(3) }
14 ```
15
16 It can be fixed by adjusting the trait bound like this:
17
18 ```
19 #![feature(unboxed_closures)]
20
21 fn foo<F: Fn<(i32,)>>(f: F) -> F::Output { f(3) }
22 ```
23
24 Note that `(T,)` always denotes the type of a 1-tuple containing an element of
25 type `T`. The comma is necessary for syntactic disambiguation.