]> git.proxmox.com Git - rustc.git/blob - compiler/rustc_error_codes/src/error_codes/E0121.md
New upstream version 1.68.2+dfsg1
[rustc.git] / compiler / rustc_error_codes / src / error_codes / E0121.md
1 The type placeholder `_` was used within a type on an item's signature.
2
3 Erroneous code example:
4
5 ```compile_fail,E0121
6 fn foo() -> _ { 5 } // error
7
8 static BAR: _ = "test"; // error
9 ```
10
11 In those cases, you need to provide the type explicitly:
12
13 ```
14 fn foo() -> i32 { 5 } // ok!
15
16 static BAR: &str = "test"; // ok!
17 ```
18
19 The type placeholder `_` can be used outside item's signature as follows:
20
21 ```
22 let x = "a4a".split('4')
23 .collect::<Vec<_>>(); // No need to precise the Vec's generic type.
24 ```