Skip to content

Commit

Permalink
Clean up E0637 explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jun 1, 2020
1 parent 698c5c6 commit 576a97b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/librustc_error_codes/error_codes/E0637.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
An underscore `_` character has been used as the identifier for a lifetime.

Erroneous example:
Erroneous code example:

```compile_fail,E0106,E0637
fn longest<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
//^^ `'_` is a reserved lifetime name
Expand All @@ -11,13 +12,15 @@ fn longest<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
}
}
```

`'_`, cannot be used as a lifetime identifier because it is a reserved for the
anonymous lifetime. To fix this, use a lowercase letter such as 'a, or a series
of lowercase letters such as `'foo`. For more information, see [the
book][bk-no]. For more information on using the anonymous lifetime in rust
nightly, see [the nightly book][bk-al].

Corrected example:

```
fn longest<'a>(str1: &'a str, str2: &'a str) -> &'a str {
if str1.len() > str2.len() {
Expand Down

0 comments on commit 576a97b

Please sign in to comment.