Skip to content

Commit be3fcf4

Browse files
authored
Rollup merge of rust-lang#66186 - GuillaumeGomez:long-err-explanation-E0623, r=Dylan-DPC
Add long error explanation for E0623 Part of rust-lang#61137. r? @Dylan-DPC
2 parents 6eea500 + fd868d4 commit be3fcf4

File tree

71 files changed

+123
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+123
-9
lines changed

src/librustc/error_codes.rs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,51 @@ fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {
18961896
```
18971897
"##,
18981898

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` is unrelated to `'short`). We can solve this issue in
1916+
two different ways:
1917+
1918+
Either we make `'short` live at least as long as `'long`:
1919+
1920+
```
1921+
struct Foo<'a> {
1922+
x: &'a isize,
1923+
}
1924+
1925+
// we set 'short to live at least as long as 'long
1926+
fn bar<'short: 'long, 'long>(c: Foo<'short>, l: &'long isize) {
1927+
let _: Foo<'long> = c; // ok!
1928+
}
1929+
```
1930+
1931+
Or we use only one lifetime:
1932+
1933+
```
1934+
struct Foo<'a> {
1935+
x: &'a isize,
1936+
}
1937+
1938+
fn bar<'short>(c: Foo<'short>, l: &'short isize) {
1939+
let _: Foo<'short> = c; // ok!
1940+
}
1941+
```
1942+
"##,
1943+
18991944
E0635: r##"
19001945
The `#![feature]` attribute specified an unknown feature.
19011946
@@ -2329,7 +2374,6 @@ the future, [RFC 2091] prohibits their implementation without a follow-up RFC.
23292374
E0488, // lifetime of variable does not enclose its declaration
23302375
E0489, // type/lifetime parameter not in scope here
23312376
E0490, // a value of type `..` is borrowed for too long
2332-
E0623, // lifetime mismatch where both parameters are anonymous regions
23332377
E0628, // generators cannot have explicit parameters
23342378
E0631, // type mismatch in closure arguments
23352379
E0637, // "'_" is not a valid lifetime bound

src/test/ui/associated-type-bounds/implied-region-constraints.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ LL | let _failure_proves_not_implied_outlives_region_b: &'b T = &x;
1818

1919
error: aborting due to 2 previous errors
2020

21+
For more information about this error, try `rustc --explain E0623`.

src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ LL | let z: I::A = if cond { x } else { y };
1111

1212
error: aborting due to previous error
1313

14+
For more information about this error, try `rustc --explain E0623`.

src/test/ui/associated-types/associated-types-subtyping-1.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ LL | let _c: <T as Trait<'a>>::Type = b;
1818

1919
error: aborting due to 2 previous errors
2020

21+
For more information about this error, try `rustc --explain E0623`.

src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ LL | (a, b)
2222

2323
error: aborting due to 2 previous errors
2424

25+
For more information about this error, try `rustc --explain E0623`.

src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ LL | let b = bar(foo, x);
2121

2222
error: aborting due to 2 previous errors
2323

24+
For more information about this error, try `rustc --explain E0623`.

src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ LL | let b = bar(f, y);
1111

1212
error: aborting due to previous error
1313

14+
For more information about this error, try `rustc --explain E0623`.

src/test/ui/async-await/issues/issue-63388-1.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ LL | foo
1111

1212
error: aborting due to previous error
1313

14+
For more information about this error, try `rustc --explain E0623`.

src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<
99

1010
error: aborting due to previous error
1111

12+
For more information about this error, try `rustc --explain E0623`.

src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ LL | S { pointer: &mut *p.pointer }
1010

1111
error: aborting due to previous error
1212

13+
For more information about this error, try `rustc --explain E0623`.

0 commit comments

Comments
 (0)