]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0632.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0632.md
1 An explicit generic argument was provided when calling a function that
2 uses `impl Trait` in argument position.
3
4 Erroneous code example:
5
6 ```compile_fail,E0632
7 fn foo<T: Copy>(a: T, b: impl Clone) {}
8
9 foo::<i32>(0i32, "abc".to_string());
10 ```
11
12 Either all generic arguments should be inferred at the call site, or
13 the function definition should use an explicit generic type parameter
14 instead of `impl Trait`. Example:
15
16 ```
17 fn foo<T: Copy>(a: T, b: impl Clone) {}
18 fn bar<T: Copy, U: Clone>(a: T, b: U) {}
19
20 foo(0i32, "abc".to_string());
21
22 bar::<i32, String>(0i32, "abc".to_string());
23 bar::<_, _>(0i32, "abc".to_string());
24 bar(0i32, "abc".to_string());
25 ```