Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Clean up E0263 explanation
- Loading branch information
1 parent
320ada6
commit 019ca55
Showing
1 changed file
with
13 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
A lifetime name cannot be declared more than once in the same scope. For | ||
example: | ||
A lifetime was declared more than once in the same scope. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0263 | ||
// error, lifetime name `'a` declared twice in the same scope | ||
fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str) { } | ||
fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str, z: &'a str) { // error! | ||
} | ||
``` | ||
|
||
Two lifetimes cannot have the same name. To fix this example, change | ||
the second `'a` lifetime into something else (`'c` for example): | ||
|
||
``` | ||
fn foo<'a, 'b, 'c>(x: &'a str, y: &'b str, z: &'c str) { // ok! | ||
} | ||
``` |