]> git.proxmox.com Git - rustc.git/blame - src/librustc_error_codes/error_codes/E0059.md
New upstream version 1.47.0+dfsg1
[rustc.git] / src / librustc_error_codes / error_codes / E0059.md
CommitLineData
60c5eb7d
XL
1The built-in function traits are generic over a tuple of the function arguments.
2If 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
4tuple. Otherwise function call notation cannot be used and the trait will not be
5implemented by closures.
6
7The most likely source of this error is using angle-bracket notation without
8wrapping the function argument type into a tuple, for example:
9
10```compile_fail,E0059
11#![feature(unboxed_closures)]
12
13fn foo<F: Fn<i32>>(f: F) -> F::Output { f(3) }
14```
15
16It can be fixed by adjusting the trait bound like this:
17
18```
19#![feature(unboxed_closures)]
20
21fn foo<F: Fn<(i32,)>>(f: F) -> F::Output { f(3) }
22```
23
24Note that `(T,)` always denotes the type of a 1-tuple containing an element of
25type `T`. The comma is necessary for syntactic disambiguation.