@@ -1896,6 +1896,49 @@ fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {
1896
1896
```
1897
1897
"## ,
1898
1898
1899
+ E0623 : r##"
1900
+ A lifetime didn't match what was expected.
1901
+
1902
+ Erroneous code example:
1903
+
1904
+ ```compile_fail,E0623
1905
+ struct Foo<'a> {
1906
+ x: &'a isize,
1907
+ }
1908
+
1909
+ fn bar<'short, 'long>(c: Foo<'short>, l: &'long isize) {
1910
+ let _: Foo<'long> = c; // error!
1911
+ }
1912
+ ```
1913
+
1914
+ In this example, we tried to set a value with an incompatible lifetime to
1915
+ another one (`'long` != `'short`). We can solve this issue in two different
1916
+ ways: either we make `'short` lives longer than `'long`:
1917
+
1918
+ ```
1919
+ struct Foo<'a> {
1920
+ x: &'a isize,
1921
+ }
1922
+
1923
+ // we set 'short to outlive 'long
1924
+ fn bar<'short: 'long, 'long>(c: Foo<'short>, l: &'long isize) {
1925
+ let _: Foo<'long> = c; // ok!
1926
+ }
1927
+ ```
1928
+
1929
+ Or we use only one lifetime:
1930
+
1931
+ ```
1932
+ struct Foo<'a> {
1933
+ x: &'a isize,
1934
+ }
1935
+
1936
+ fn bar<'short>(c: Foo<'short>, l: &'short isize) {
1937
+ let _: Foo<'short> = c; // ok!
1938
+ }
1939
+ ```
1940
+ "## ,
1941
+
1899
1942
E0635 : r##"
1900
1943
The `#![feature]` attribute specified an unknown feature.
1901
1944
@@ -2329,7 +2372,6 @@ the future, [RFC 2091] prohibits their implementation without a follow-up RFC.
2329
2372
E0488 , // lifetime of variable does not enclose its declaration
2330
2373
E0489 , // type/lifetime parameter not in scope here
2331
2374
E0490 , // a value of type `..` is borrowed for too long
2332
- E0623 , // lifetime mismatch where both parameters are anonymous regions
2333
2375
E0628 , // generators cannot have explicit parameters
2334
2376
E0631 , // type mismatch in closure arguments
2335
2377
E0637 , // "'_" is not a valid lifetime bound
0 commit comments