diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-12-19 13:45:36 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-12-19 13:45:36 +0100 |
| commit | 94d207f4b27ba45b8d33e7e73d0829074a02117d (patch) | |
| tree | 1e85db1fec6084325a7436df52f351b6185c93c0 /src/librustc_error_codes | |
| parent | 020be74f6bc5131b79a46d94a1111c35b187469a (diff) | |
| download | rust-94d207f4b27ba45b8d33e7e73d0829074a02117d.tar.gz rust-94d207f4b27ba45b8d33e7e73d0829074a02117d.zip | |
Clean up E0121 long explanation
Diffstat (limited to 'src/librustc_error_codes')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0121.md | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/librustc_error_codes/error_codes/E0121.md b/src/librustc_error_codes/error_codes/E0121.md index 069d0fc48fb..6c20b2803cb 100644 --- a/src/librustc_error_codes/error_codes/E0121.md +++ b/src/librustc_error_codes/error_codes/E0121.md @@ -1,10 +1,24 @@ -In order to be consistent with Rust's lack of global type inference, -type and const placeholders are disallowed by design in item signatures. +The type placeholder `_` was used withing a type on an item's signature. -Examples of this error include: +Erroneous code example: ```compile_fail,E0121 -fn foo() -> _ { 5 } // error, explicitly write out the return type instead +fn foo() -> _ { 5 } // error -static BAR: _ = "test"; // error, explicitly write out the type instead +static BAR: _ = "test"; // error +``` + +In those cases, you need to provide the type explicitly: + +``` +fn foo() -> i32 { 5 } // ok! + +static BAR: &str = "test"; // ok! +``` + +The type placeholder `_` can be used outside item's signature as follows: + +``` +let x = "a4a".split('4') + .collect::<Vec<_>>(); // No need to precise the Vec's generic type. ``` |
