Skip to content

Commit 411f94c

Browse files
move E0623 into the new error code format
1 parent 356da40 commit 411f94c

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/librustc_error_codes/error_codes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ E0619: include_str!("./error_codes/E0619.md"),
338338
E0620: include_str!("./error_codes/E0620.md"),
339339
E0621: include_str!("./error_codes/E0621.md"),
340340
E0622: include_str!("./error_codes/E0622.md"),
341+
E0623: include_str!("./error_codes/E0623.md"),
341342
E0624: include_str!("./error_codes/E0624.md"),
342343
E0626: include_str!("./error_codes/E0626.md"),
343344
E0633: include_str!("./error_codes/E0633.md"),
@@ -565,7 +566,6 @@ E0743: include_str!("./error_codes/E0743.md"),
565566
// E0611, // merged into E0616
566567
// E0612, // merged into E0609
567568
// E0613, // Removed (merged with E0609)
568-
E0623, // lifetime mismatch where both parameters are anonymous regions
569569
E0625, // thread-local statics cannot be accessed at compile-time
570570
E0627, // yield statement outside of generator literal
571571
E0628, // generators cannot have explicit parameters
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
A lifetime didn't match what was expected.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0623
6+
struct Foo<'a> {
7+
x: &'a isize,
8+
}
9+
10+
fn bar<'short, 'long>(c: Foo<'short>, l: &'long isize) {
11+
let _: Foo<'long> = c; // error!
12+
}
13+
```
14+
15+
In this example, we tried to set a value with an incompatible lifetime to
16+
another one (`'long` is unrelated to `'short`). We can solve this issue in
17+
two different ways:
18+
19+
Either we make `'short` live at least as long as `'long`:
20+
21+
```
22+
struct Foo<'a> {
23+
x: &'a isize,
24+
}
25+
26+
// we set 'short to live at least as long as 'long
27+
fn bar<'short: 'long, 'long>(c: Foo<'short>, l: &'long isize) {
28+
let _: Foo<'long> = c; // ok!
29+
}
30+
```
31+
32+
Or we use only one lifetime:
33+
34+
```
35+
struct Foo<'a> {
36+
x: &'a isize,
37+
}
38+
fn bar<'short>(c: Foo<'short>, l: &'short isize) {
39+
let _: Foo<'short> = c; // ok!
40+
}
41+
```

0 commit comments

Comments
 (0)