File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
src/librustc_error_codes/error_codes Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 11An underscore ` _ ` character has been used as the identifier for a lifetime.
22
3- Erroneous example:
3+ Erroneous code example:
4+
45``` compile_fail,E0106,E0637
56fn longest<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
67 //^^ `'_` is a reserved lifetime name
@@ -11,13 +12,15 @@ fn longest<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
1112 }
1213}
1314```
15+
1416` '_ ` , cannot be used as a lifetime identifier because it is a reserved for the
1517anonymous lifetime. To fix this, use a lowercase letter such as 'a, or a series
1618of lowercase letters such as ` 'foo ` . For more information, see [ the
1719book] [ bk-no ] . For more information on using the anonymous lifetime in rust
1820nightly, see [ the nightly book] [ bk-al ] .
1921
2022Corrected example:
23+
2124```
2225fn longest<'a>(str1: &'a str, str2: &'a str) -> &'a str {
2326 if str1.len() > str2.len() {
You can’t perform that action at this time.
0 commit comments