Skip to content

Commit 3ff0aa5

Browse files
authored
Rollup merge of #143231 - xizheyin:143152, r=fee1-dead
Suggest use another lifetime specifier instead of underscore lifetime cc #143152 r? compiler
2 parents 4f44014 + e7c3703 commit 3ff0aa5

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

compiler/rustc_resolve/messages.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ resolve_undeclared_label =
432432
433433
resolve_underscore_lifetime_is_reserved = `'_` cannot be used here
434434
.label = `'_` is a reserved lifetime name
435+
.help = use another lifetime specifier
435436
436437
resolve_unexpected_res_change_ty_to_const_param_sugg =
437438
you might have meant to write a const parameter here

compiler/rustc_resolve/src/errors.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@ pub(crate) struct ImplicitElidedLifetimeNotAllowedHere {
934934

935935
#[derive(Diagnostic)]
936936
#[diag(resolve_underscore_lifetime_is_reserved, code = E0637)]
937+
#[help]
937938
pub(crate) struct UnderscoreLifetimeIsReserved {
938939
#[primary_span]
939940
#[label]

tests/ui/error-codes/E0637.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ error[E0637]: `'_` cannot be used here
33
|
44
LL | fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
55
| ^^ `'_` is a reserved lifetime name
6+
|
7+
= help: use another lifetime specifier
68

79
error[E0106]: missing lifetime specifier
810
--> $DIR/E0637.rs:1:62

tests/ui/underscore-lifetime/in-binder.stderr

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,48 @@ error[E0637]: `'_` cannot be used here
33
|
44
LL | impl<'_> IceCube<'_> {}
55
| ^^ `'_` is a reserved lifetime name
6+
|
7+
= help: use another lifetime specifier
68

79
error[E0637]: `'_` cannot be used here
810
--> $DIR/in-binder.rs:12:15
911
|
1012
LL | struct Struct<'_> {
1113
| ^^ `'_` is a reserved lifetime name
14+
|
15+
= help: use another lifetime specifier
1216

1317
error[E0637]: `'_` cannot be used here
1418
--> $DIR/in-binder.rs:17:11
1519
|
1620
LL | enum Enum<'_> {
1721
| ^^ `'_` is a reserved lifetime name
22+
|
23+
= help: use another lifetime specifier
1824

1925
error[E0637]: `'_` cannot be used here
2026
--> $DIR/in-binder.rs:22:13
2127
|
2228
LL | union Union<'_> {
2329
| ^^ `'_` is a reserved lifetime name
30+
|
31+
= help: use another lifetime specifier
2432

2533
error[E0637]: `'_` cannot be used here
2634
--> $DIR/in-binder.rs:27:13
2735
|
2836
LL | trait Trait<'_> {
2937
| ^^ `'_` is a reserved lifetime name
38+
|
39+
= help: use another lifetime specifier
3040

3141
error[E0637]: `'_` cannot be used here
3242
--> $DIR/in-binder.rs:31:8
3343
|
3444
LL | fn foo<'_>() {
3545
| ^^ `'_` is a reserved lifetime name
46+
|
47+
= help: use another lifetime specifier
3648

3749
error: aborting due to 6 previous errors
3850

tests/ui/underscore-lifetime/underscore-lifetime-binders.stderr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ error[E0637]: `'_` cannot be used here
1515
|
1616
LL | fn foo<'_>
1717
| ^^ `'_` is a reserved lifetime name
18+
|
19+
= help: use another lifetime specifier
1820

1921
error[E0637]: `'_` cannot be used here
2022
--> $DIR/underscore-lifetime-binders.rs:10:25
2123
|
2224
LL | fn meh() -> Box<dyn for<'_> Meh<'_>>
2325
| ^^ `'_` is a reserved lifetime name
26+
|
27+
= help: use another lifetime specifier
2428

2529
error[E0106]: missing lifetime specifier
2630
--> $DIR/underscore-lifetime-binders.rs:10:33

0 commit comments

Comments
 (0)