Skip to content

Commit 576a97b

Browse files
Clean up E0637 explanation
1 parent 698c5c6 commit 576a97b

File tree

1 file changed

+4
-1
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+4
-1
lines changed

src/librustc_error_codes/error_codes/E0637.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
An 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
56
fn 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
1517
anonymous lifetime. To fix this, use a lowercase letter such as 'a, or a series
1618
of lowercase letters such as `'foo`. For more information, see [the
1719
book][bk-no]. For more information on using the anonymous lifetime in rust
1820
nightly, see [the nightly book][bk-al].
1921

2022
Corrected example:
23+
2124
```
2225
fn longest<'a>(str1: &'a str, str2: &'a str) -> &'a str {
2326
if str1.len() > str2.len() {

0 commit comments

Comments
 (0)