Skip to content

Commit 531f235

Browse files
authored
Rollup merge of rust-lang#68908 - jwhite927:E0637, r=Dylan-DPC
Add long error code explanation message for E0637 Reference issue [rust-lang#61137](rust-lang#61137) To incorporate a long error description for E0637, I have made the necessary modification to error_codes.rs and added error_codes/E0637.md, and blessed the relevant .stderror files. ~~, however when I build rustc stage 1, I am unable to make `$ rustc --explain E0637` work even though rustc appears to be able to call up the long error explanations for other errors. I wanted to guarantee this would work before moving on the blessing the various ui tests that have been affected. @GuillaumeGomez Do you know the most likely reason(s) why this would be the case?~~ Update: `$ rustc --explain E0637` works now.
2 parents 1e26a1c + d705ad2 commit 531f235

17 files changed

+50
-3
lines changed

src/librustc_error_codes/error_codes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ E0631: include_str!("./error_codes/E0631.md"),
353353
E0633: include_str!("./error_codes/E0633.md"),
354354
E0635: include_str!("./error_codes/E0635.md"),
355355
E0636: include_str!("./error_codes/E0636.md"),
356+
E0637: include_str!("./error_codes/E0637.md"),
356357
E0638: include_str!("./error_codes/E0638.md"),
357358
E0639: include_str!("./error_codes/E0639.md"),
358359
E0641: include_str!("./error_codes/E0641.md"),
@@ -584,7 +585,6 @@ E0746: include_str!("./error_codes/E0746.md"),
584585
E0632, // cannot provide explicit generic arguments when `impl Trait` is
585586
// used in argument position
586587
E0634, // type has conflicting packed representaton hints
587-
E0637, // "'_" is not a valid lifetime bound
588588
E0640, // infer outlives requirements
589589
// E0645, // trait aliases not finished
590590
E0657, // `impl Trait` can only capture lifetimes bound at the fn level
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
An underscore `_` character has been used as the identifier for a lifetime.
2+
3+
Erroneous example:
4+
```compile_fail,E0106,E0637
5+
fn longest<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
6+
//^^ `'_` is a reserved lifetime name
7+
if str1.len() > str2.len() {
8+
str1
9+
} else {
10+
str2
11+
}
12+
}
13+
```
14+
`'_`, cannot be used as a lifetime identifier because it is a reserved for the
15+
anonymous lifetime. To fix this, use a lowercase letter such as 'a, or a series
16+
of lowercase letters such as `'foo`. For more information, see [the
17+
book][bk-no]. For more information on using the anonymous lifetime in rust
18+
nightly, see [the nightly book][bk-al].
19+
20+
Corrected example:
21+
```
22+
fn longest<'a>(str1: &'a str, str2: &'a str) -> &'a str {
23+
if str1.len() > str2.len() {
24+
str1
25+
} else {
26+
str2
27+
}
28+
}
29+
```
30+
31+
[bk-no]: https://doc.rust-lang.org/book/appendix-02-operators.html#non-operator-symbols
32+
[bk-al]: https://doc.rust-lang.org/nightly/edition-guide/rust-2018/ownership-and-lifetimes/the-anonymous-lifetime.html

src/test/ui/const-generics/const-param-elided-lifetime.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ LL | #![feature(const_generics)]
3838

3939
error: aborting due to 5 previous errors
4040

41+
For more information about this error, try `rustc --explain E0637`.

src/test/ui/error-codes/E0637.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ LL | impl<'a: '_> Bar<'a> {
1818

1919
error: aborting due to 3 previous errors
2020

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

src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ LL | fn bar<'b, L: X<&'b Nested<i32>>>(){}
1818

1919
error: aborting due to 3 previous errors
2020

21-
For more information about this error, try `rustc --explain E0106`.
21+
Some errors have detailed explanations: E0106, E0637.
22+
For more information about an error, try `rustc --explain E0106`.

src/test/ui/underscore-lifetime/in-binder.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ LL | fn foo<'_>() {
3636

3737
error: aborting due to 6 previous errors
3838

39+
For more information about this error, try `rustc --explain E0637`.

src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ LL | fn foo2<'a>(_: &'a u8, y: &'a u8) -> &'a u8 { y }
3838

3939
error: aborting due to 5 previous errors
4040

41-
For more information about this error, try `rustc --explain E0106`.
41+
Some errors have detailed explanations: E0106, E0637.
42+
For more information about an error, try `rustc --explain E0106`.

src/test/ui/underscore-lifetime/underscore-outlives-bounds.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | impl<'b: '_> Foo<'b> for i32 {}
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0637`.

src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2015.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | T: WithType<&u32>
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0637`.

src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2018.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | T: WithType<&u32>
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0637`.

src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rust2015.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | T: WithRegion<'_>
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0637`.

src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rust2018.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | T: WithRegion<'_>
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0637`.

src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2015.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | T: WithType<&u32>
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0637`.

src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2018.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | T: WithType<&u32>
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0637`.

src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rust2015.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | T: WithRegion<'_>
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0637`.

src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rust2018.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | T: WithRegion<'_>
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0637`.

src/test/ui/underscore-lifetime/where-clauses.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ LL | impl<T: '_> Foo<'static> for Vec<T> {}
1212

1313
error: aborting due to 2 previous errors
1414

15+
For more information about this error, try `rustc --explain E0637`.

0 commit comments

Comments
 (0)