Skip to content

Commit 9e472c2

Browse files
committed
Auto merge of #52450 - PramodBisht:issue/52413, r=estebank
Closes #52413: Provide structured suggestion instead of label Provide structured suggestion instead of label r? @estebank
2 parents 11a9024 + 49b0a1e commit 9e472c2

File tree

40 files changed

+62
-52
lines changed

40 files changed

+62
-52
lines changed

src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
6565
region_info
6666
);
6767

68-
let (arg, new_ty, br, is_first, scope_def_id, is_impl_item) = (
68+
let (arg, new_ty, new_ty_span, br, is_first, scope_def_id, is_impl_item) = (
6969
anon_arg_info.arg,
7070
anon_arg_info.arg_ty,
71+
anon_arg_info.arg_ty_span,
7172
anon_arg_info.bound_region,
7273
anon_arg_info.is_first,
7374
region_info.def_id,
@@ -110,9 +111,10 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
110111
E0621,
111112
"explicit lifetime required in {}",
112113
error_var
113-
).span_label(
114-
arg.pat.span,
115-
format!("consider changing {} to `{}`", span_label_var, new_ty),
114+
).span_suggestion(
115+
new_ty_span,
116+
&format!("add explicit lifetime `{}` to {}", named, span_label_var),
117+
new_ty.to_string()
116118
)
117119
.span_label(span, format!("lifetime `{}` required", named))
118120
.emit();

src/librustc/infer/error_reporting/nice_region_error/util.rs

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ pub(super) struct AnonymousArgInfo<'tcx> {
2727
pub arg_ty: Ty<'tcx>,
2828
// the ty::BoundRegion corresponding to the anonymous region
2929
pub bound_region: ty::BoundRegion,
30+
// arg_ty_span contains span of argument type
31+
pub arg_ty_span : Span,
3032
// corresponds to id the argument is the first parameter
3133
// in the declaration
3234
pub is_first: bool,
@@ -74,12 +76,16 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
7476
if let Some(node_id) = hir.as_local_node_id(id) {
7577
if let Some(body_id) = hir.maybe_body_owned_by(node_id) {
7678
let body = hir.body(body_id);
79+
let owner_id = hir.body_owner(body_id);
80+
let fn_decl = hir.fn_decl(owner_id).unwrap();
7781
if let Some(tables) = self.tables {
7882
body.arguments
7983
.iter()
8084
.enumerate()
8185
.filter_map(|(index, arg)| {
8286
// May return None; sometimes the tables are not yet populated.
87+
let ty_hir_id = fn_decl.inputs[index].hir_id;
88+
let arg_ty_span = hir.span(hir.hir_to_node_id(ty_hir_id));
8389
let ty = tables.node_id_to_type_opt(arg.hir_id)?;
8490
let mut found_anon_region = false;
8591
let new_arg_ty = self.tcx.fold_regions(&ty, &mut false, |r, _| {
@@ -95,6 +101,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
95101
Some(AnonymousArgInfo {
96102
arg: arg,
97103
arg_ty: new_arg_ty,
104+
arg_ty_span : arg_ty_span,
98105
bound_region: bound_region,
99106
is_first: is_first,
100107
})

src/test/ui/in-band-lifetimes/mismatched.nll.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ error[E0621]: explicit lifetime required in the type of `y`
1414
--> $DIR/mismatched.rs:14:42
1515
|
1616
LL | fn foo(x: &'a u32, y: &u32) -> &'a u32 { y } //~ ERROR explicit lifetime required
17-
| - ^ lifetime `'a` required
18-
| |
19-
| consider changing the type of `y` to `&'a u32`
17+
| ---- ^ lifetime `'a` required
18+
| |
19+
| help: add explicit lifetime `'a` to the type of `y`: `&'a u32`
2020

2121
error: unsatisfied lifetime constraints
2222
--> $DIR/mismatched.rs:16:46

src/test/ui/in-band-lifetimes/mismatched.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ error[E0621]: explicit lifetime required in the type of `y`
22
--> $DIR/mismatched.rs:14:42
33
|
44
LL | fn foo(x: &'a u32, y: &u32) -> &'a u32 { y } //~ ERROR explicit lifetime required
5-
| - ^ lifetime `'a` required
6-
| |
7-
| consider changing the type of `y` to `&'a u32`
5+
| ---- ^ lifetime `'a` required
6+
| |
7+
| help: add explicit lifetime `'a` to the type of `y`: `&'a u32`
88

99
error[E0623]: lifetime mismatch
1010
--> $DIR/mismatched.rs:16:46

src/test/ui/in-band-lifetimes/mismatched_trait.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `y`
88
--> $DIR/mismatched_trait.rs:16:9
99
|
1010
LL | fn baz(&self, x: &'a u32, y: &u32) -> &'a u32 {
11-
| - consider changing the type of `y` to `&'a u32`
11+
| ---- help: add explicit lifetime `'a` to the type of `y`: `&'a u32`
1212
LL | y //~ ERROR explicit lifetime required
1313
| ^ lifetime `'a` required
1414

src/test/ui/in-band-lifetimes/mismatched_trait.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `y`
22
--> $DIR/mismatched_trait.rs:16:9
33
|
44
LL | fn baz(&self, x: &'a u32, y: &u32) -> &'a u32 {
5-
| - consider changing the type of `y` to `&'a u32`
5+
| ---- help: add explicit lifetime `'a` to the type of `y`: `&'a u32`
66
LL | y //~ ERROR explicit lifetime required
77
| ^ lifetime `'a` required
88

src/test/ui/issue-13058.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `cont`
22
--> $DIR/issue-13058.rs:24:26
33
|
44
LL | fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool
5-
| ---- consider changing the type of `cont` to `&'r T`
5+
| -- help: add explicit lifetime `'r` to the type of `cont`: `&'r T`
66
LL | {
77
LL | let cont_iter = cont.iter();
88
| ^^^^ lifetime `'r` required

src/test/ui/issue-14285.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `a`
88
--> $DIR/issue-14285.rs:22:7
99
|
1010
LL | fn foo<'a>(a: &Foo) -> B<'a> {
11-
| - consider changing the type of `a` to `&'a (dyn Foo + 'a)`
11+
| ---- help: add explicit lifetime `'a` to the type of `a`: `&'a (dyn Foo + 'a)`
1212
LL | B(a) //~ ERROR 22:5: 22:9: explicit lifetime required in the type of `a` [E0621]
1313
| ^ lifetime `'a` required
1414

src/test/ui/issue-14285.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `a`
22
--> $DIR/issue-14285.rs:22:5
33
|
44
LL | fn foo<'a>(a: &Foo) -> B<'a> {
5-
| - consider changing the type of `a` to `&'a (dyn Foo + 'a)`
5+
| ---- help: add explicit lifetime `'a` to the type of `a`: `&'a (dyn Foo + 'a)`
66
LL | B(a) //~ ERROR 22:5: 22:9: explicit lifetime required in the type of `a` [E0621]
77
| ^^^^ lifetime `'a` required
88

src/test/ui/issue-15034.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `lexer`
88
--> $DIR/issue-15034.rs:27:25
99
|
1010
LL | pub fn new(lexer: &'a mut Lexer) -> Parser<'a> {
11-
| ----- consider changing the type of `lexer` to `&'a mut Lexer<'a>`
11+
| ------------- help: add explicit lifetime `'a` to the type of `lexer`: `&'a mut Lexer<'a>`
1212
LL | Parser { lexer: lexer }
1313
| ^^^^^ lifetime `'a` required
1414

src/test/ui/issue-15034.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `lexer`
22
--> $DIR/issue-15034.rs:27:25
33
|
44
LL | pub fn new(lexer: &'a mut Lexer) -> Parser<'a> {
5-
| ----- consider changing the type of `lexer` to `&'a mut Lexer<'a>`
5+
| ------------- help: add explicit lifetime `'a` to the type of `lexer`: `&'a mut Lexer<'a>`
66
LL | Parser { lexer: lexer }
77
| ^^^^^ lifetime `'a` required
88

src/test/ui/issue-16922.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `value`
88
--> $DIR/issue-16922.rs:14:5
99
|
1010
LL | fn foo<T: Any>(value: &T) -> Box<Any> {
11-
| ----- consider changing the type of `value` to `&'static T`
11+
| -- help: add explicit lifetime `'static` to the type of `value`: `&'static T`
1212
LL | Box::new(value) as Box<Any>
1313
| ^^^^^^^^^^^^^^^ lifetime `'static` required
1414

src/test/ui/issue-16922.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `value`
22
--> $DIR/issue-16922.rs:14:5
33
|
44
LL | fn foo<T: Any>(value: &T) -> Box<Any> {
5-
| ----- consider changing the type of `value` to `&'static T`
5+
| -- help: add explicit lifetime `'static` to the type of `value`: `&'static T`
66
LL | Box::new(value) as Box<Any>
77
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required
88

src/test/ui/issue-3154.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ error[E0621]: explicit lifetime required in the type of `x`
1414
--> $DIR/issue-3154.rs:16:15
1515
|
1616
LL | fn thing<'a,Q>(x: &Q) -> thing<'a,Q> {
17-
| - consider changing the type of `x` to `&'a Q`
17+
| -- help: add explicit lifetime `'a` to the type of `x`: `&'a Q`
1818
LL | thing{ x: x } //~ ERROR 16:5: 16:18: explicit lifetime required in the type of `x` [E0621]
1919
| ^ lifetime `'a` required
2020

src/test/ui/issue-3154.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `x`
22
--> $DIR/issue-3154.rs:16:5
33
|
44
LL | fn thing<'a,Q>(x: &Q) -> thing<'a,Q> {
5-
| - consider changing the type of `x` to `&'a Q`
5+
| -- help: add explicit lifetime `'a` to the type of `x`: `&'a Q`
66
LL | thing{ x: x } //~ ERROR 16:5: 16:18: explicit lifetime required in the type of `x` [E0621]
77
| ^^^^^^^^^^^^^ lifetime `'a` required
88

src/test/ui/issue-40288-2.nll.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ error[E0621]: explicit lifetime required in the type of `y`
3838
--> $DIR/issue-40288-2.rs:17:9
3939
|
4040
LL | fn lifetime_transmute_slice<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T {
41-
| - consider changing the type of `y` to `&'a T`
41+
| -- help: add explicit lifetime `'a` to the type of `y`: `&'a T`
4242
...
4343
LL | slice[0] = y;
4444
| ^^^^^^^^^^^^ lifetime `'a` required
@@ -47,7 +47,7 @@ error[E0621]: explicit lifetime required in the type of `y`
4747
--> $DIR/issue-40288-2.rs:32:9
4848
|
4949
LL | fn lifetime_transmute_struct<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T {
50-
| - consider changing the type of `y` to `&'a T`
50+
| -- help: add explicit lifetime `'a` to the type of `y`: `&'a T`
5151
...
5252
LL | dst.head = y;
5353
| ^^^^^^^^^^^^ lifetime `'a` required

src/test/ui/issue-40288-2.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `y`
22
--> $DIR/issue-40288-2.rs:19:5
33
|
44
LL | fn lifetime_transmute_slice<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T {
5-
| - consider changing the type of `y` to `&'a T`
5+
| -- help: add explicit lifetime `'a` to the type of `y`: `&'a T`
66
...
77
LL | out[0]
88
| ^^^^^^ lifetime `'a` required
@@ -11,7 +11,7 @@ error[E0621]: explicit lifetime required in the type of `y`
1111
--> $DIR/issue-40288-2.rs:34:5
1212
|
1313
LL | fn lifetime_transmute_struct<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T {
14-
| - consider changing the type of `y` to `&'a T`
14+
| -- help: add explicit lifetime `'a` to the type of `y`: `&'a T`
1515
...
1616
LL | out.head
1717
| ^^^^^^^^ lifetime `'a` required

src/test/ui/issue-46983.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `x`
22
--> $DIR/issue-46983.rs:14:5
33
|
44
LL | fn foo(x: &u32) -> &'static u32 {
5-
| - consider changing the type of `x` to `&'static u32`
5+
| ---- help: add explicit lifetime `'static` to the type of `x`: `&'static u32`
66
LL | &*x
77
| ^^^ lifetime `'static` required
88

src/test/ui/lifetime-errors/42701_one_named_and_one_anonymous.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `x`
88
--> $DIR/42701_one_named_and_one_anonymous.rs:16:5
99
|
1010
LL | fn foo2<'a>(a: &'a Foo, x: &i32) -> &'a i32 {
11-
| - consider changing the type of `x` to `&'a i32`
11+
| ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
1212
LL | / if true {
1313
LL | | let p: &i32 = &a.field;
1414
LL | | &*p

src/test/ui/lifetime-errors/42701_one_named_and_one_anonymous.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `x`
22
--> $DIR/42701_one_named_and_one_anonymous.rs:20:9
33
|
44
LL | fn foo2<'a>(a: &'a Foo, x: &i32) -> &'a i32 {
5-
| - consider changing the type of `x` to `&'a i32`
5+
| ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
66
...
77
LL | &*x //~ ERROR explicit lifetime
88
| ^^^ lifetime `'a` required

src/test/ui/lifetime-errors/ex1-return-one-existing-name-early-bound-in-struct.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `other`
88
--> $DIR/ex1-return-one-existing-name-early-bound-in-struct.rs:18:15
99
|
1010
LL | fn bar(&self, other: Foo) -> Foo<'a> {
11-
| ----- consider changing the type of `other` to `Foo<'a>`
11+
| --- help: add explicit lifetime `'a` to the type of `other`: `Foo<'a>`
1212
LL | match *self {
1313
| ^^^^^ lifetime `'a` required
1414

src/test/ui/lifetime-errors/ex1-return-one-existing-name-early-bound-in-struct.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `other`
22
--> $DIR/ex1-return-one-existing-name-early-bound-in-struct.rs:21:21
33
|
44
LL | fn bar(&self, other: Foo) -> Foo<'a> {
5-
| ----- consider changing the type of `other` to `Foo<'a>`
5+
| --- help: add explicit lifetime `'a` to the type of `other`: `Foo<'a>`
66
...
77
LL | other //~ ERROR explicit lifetime
88
| ^^^^^ lifetime `'a` required

src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-2.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `x`
88
--> $DIR/ex1-return-one-existing-name-if-else-2.rs:12:8
99
|
1010
LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
11-
| - consider changing the type of `x` to `&'a i32`
11+
| ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
1212
LL | if x > y { x } else { y } //~ ERROR explicit lifetime
1313
| ^^^^^ lifetime `'a` required
1414

src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `x`
22
--> $DIR/ex1-return-one-existing-name-if-else-2.rs:12:16
33
|
44
LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
5-
| - consider changing the type of `x` to `&'a i32`
5+
| ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
66
LL | if x > y { x } else { y } //~ ERROR explicit lifetime
77
| ^ lifetime `'a` required
88

src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.nll.stderr

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ error[E0621]: explicit lifetime required in parameter type
88
--> $DIR/ex1-return-one-existing-name-if-else-3.rs:11:16
99
|
1010
LL | fn foo<'a>((x, y): (&'a i32, &i32)) -> &'a i32 {
11-
| ----^-
12-
| | |
13-
| | lifetime `'a` required
14-
| consider changing type to `(&'a i32, &'a i32)`
11+
| ^ --------------- help: add explicit lifetime `'a` to type: `(&'a i32, &'a i32)`
12+
| |
13+
| lifetime `'a` required
1514

1615
error: aborting due to previous error
1716

src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in parameter type
22
--> $DIR/ex1-return-one-existing-name-if-else-3.rs:12:27
33
|
44
LL | fn foo<'a>((x, y): (&'a i32, &i32)) -> &'a i32 {
5-
| ------ consider changing type to `(&'a i32, &'a i32)`
5+
| --------------- help: add explicit lifetime `'a` to type: `(&'a i32, &'a i32)`
66
LL | if x > y { x } else { y } //~ ERROR explicit lifetime
77
| ^ lifetime `'a` required
88

src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `x`
88
--> $DIR/ex1-return-one-existing-name-if-else-using-impl-2.rs:14:7
99
|
1010
LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
11-
| - consider changing the type of `x` to `&'a i32`
11+
| ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
1212
LL | if x > y { x } else { y } //~ ERROR explicit lifetime
1313
| ^^^^^ lifetime `'a` required
1414

src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `x`
22
--> $DIR/ex1-return-one-existing-name-if-else-using-impl-2.rs:14:15
33
|
44
LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
5-
| - consider changing the type of `x` to `&'a i32`
5+
| ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
66
LL | if x > y { x } else { y } //~ ERROR explicit lifetime
77
| ^ lifetime `'a` required
88

src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `x`
88
--> $DIR/ex1-return-one-existing-name-if-else-using-impl-3.rs:18:5
99
|
1010
LL | fn foo<'a>(&'a self, x: &i32) -> &i32 {
11-
| - consider changing the type of `x` to `&'a i32`
11+
| ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
1212
LL |
1313
LL | if true { &self.field } else { x } //~ ERROR explicit lifetime
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required

src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `x`
22
--> $DIR/ex1-return-one-existing-name-if-else-using-impl-3.rs:18:36
33
|
44
LL | fn foo<'a>(&'a self, x: &i32) -> &i32 {
5-
| - consider changing the type of `x` to `&'a i32`
5+
| ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
66
LL |
77
LL | if true { &self.field } else { x } //~ ERROR explicit lifetime
88
| ^ lifetime `'a` required

src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `y`
88
--> $DIR/ex1-return-one-existing-name-if-else.rs:12:8
99
|
1010
LL | fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {
11-
| - consider changing the type of `y` to `&'a i32`
11+
| ---- help: add explicit lifetime `'a` to the type of `y`: `&'a i32`
1212
LL | if x > y { x } else { y } //~ ERROR explicit lifetime
1313
| ^^^^^ lifetime `'a` required
1414

src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `y`
22
--> $DIR/ex1-return-one-existing-name-if-else.rs:12:27
33
|
44
LL | fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {
5-
| - consider changing the type of `y` to `&'a i32`
5+
| ---- help: add explicit lifetime `'a` to the type of `y`: `&'a i32`
66
LL | if x > y { x } else { y } //~ ERROR explicit lifetime
77
| ^ lifetime `'a` required
88

src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0621]: explicit lifetime required in the type of `x`
88
--> $DIR/ex2a-push-one-existing-name-2.rs:16:5
99
|
1010
LL | fn foo<'a>(x: Ref<i32>, y: &mut Vec<Ref<'a, i32>>) {
11-
| - consider changing the type of `x` to `Ref<'a, i32>`
11+
| -------- help: add explicit lifetime `'a` to the type of `x`: `Ref<'a, i32>`
1212
LL | y.push(x); //~ ERROR explicit lifetime
1313
| ^^^^^^^^^ lifetime `'a` required
1414

src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `x`
22
--> $DIR/ex2a-push-one-existing-name-2.rs:16:12
33
|
44
LL | fn foo<'a>(x: Ref<i32>, y: &mut Vec<Ref<'a, i32>>) {
5-
| - consider changing the type of `x` to `Ref<'a, i32>`
5+
| -------- help: add explicit lifetime `'a` to the type of `x`: `Ref<'a, i32>`
66
LL | y.push(x); //~ ERROR explicit lifetime
77
| ^ lifetime `'a` required
88

src/test/ui/lifetime-errors/ex2a-push-one-existing-name-early-bound.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0621]: explicit lifetime required in the type of `y`
22
--> $DIR/ex2a-push-one-existing-name-early-bound.rs:17:12
33
|
44
LL | fn baz<'a, 'b, T>(x: &mut Vec<&'a T>, y: &T)
5-
| - consider changing the type of `y` to `&'a T`
5+
| -- help: add explicit lifetime `'a` to the type of `y`: `&'a T`
66
...
77
LL | x.push(y); //~ ERROR explicit lifetime required
88
| ^ lifetime `'a` required

0 commit comments

Comments
 (0)