Skip to content

Commit 53120b5

Browse files
committed
Recover missing suggestion part under NLL
1 parent 7b0db3e commit 53120b5

15 files changed

+26
-17
lines changed

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed
44
use rustc_infer::infer::{
55
error_reporting::nice_region_error::NiceRegionError,
66
error_reporting::unexpected_hidden_region_diagnostic, NllRegionVariableOrigin,
7+
RelateParamBound,
78
};
89
use rustc_middle::hir::place::PlaceBase;
910
use rustc_middle::mir::{ConstraintCategory, ReturnConstraint};
@@ -166,9 +167,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
166167
let type_test_span = type_test.locations.span(&self.body);
167168

168169
if let Some(lower_bound_region) = lower_bound_region {
170+
let generic_ty = type_test.generic_kind.to_ty(self.infcx.tcx);
171+
let origin = RelateParamBound(type_test_span, generic_ty, None);
169172
self.buffer_error(self.infcx.construct_generic_bound_failure(
170173
type_test_span,
171-
None,
174+
Some(origin),
172175
type_test.generic_kind,
173176
lower_bound_region,
174177
self.body.source.def_id().as_local(),

src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ LL | | // This function call requires that
4747
... |
4848
LL | | require(value);
4949
LL | | });
50-
| |_____^
50+
| |_____^ ...so that the type `T` will meet its required lifetime bounds
5151

5252
error: aborting due to previous error
5353

src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | fn no_region<'a, T>(x: Box<T>) -> impl Debug + 'a
55
| - help: consider adding an explicit lifetime bound...: `T: 'a`
66
...
77
LL | x
8-
| ^
8+
| ^ ...so that the type `T` will meet its required lifetime bounds
99

1010
error[E0309]: the parameter type `T` may not live long enough
1111
--> $DIR/impl-trait-outlives.rs:26:5
@@ -14,7 +14,7 @@ LL | fn wrong_region<'a, 'b, T>(x: Box<T>) -> impl Debug + 'a
1414
| - help: consider adding an explicit lifetime bound...: `T: 'a`
1515
...
1616
LL | x
17-
| ^
17+
| ^ ...so that the type `T` will meet its required lifetime bounds
1818

1919
error: aborting due to 2 previous errors
2020

src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0310]: the parameter type `T` may not live long enough
44
LL | fn generic2<T: Iterator>(value: T) {
55
| -- help: consider adding an explicit lifetime bound...: `T: 'static +`
66
LL | twice(value, |value_ref, item| invoke2(value_ref, item));
7-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
88

99
error: aborting due to previous error
1010

src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ LL | with_signature(x, |mut y| Box::new(y.next()))
3333
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
3434
|
3535
= help: consider adding an explicit lifetime bound `<T as Iterator>::Item: 'a`...
36+
= note: ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds
3637

3738
note: external requirements
3839
--> $DIR/projection-no-regions-closure.rs:34:23
@@ -96,6 +97,7 @@ LL | with_signature(x, |mut y| Box::new(y.next()))
9697
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
9798
|
9899
= help: consider adding an explicit lifetime bound `<T as Iterator>::Item: 'a`...
100+
= note: ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds
99101

100102
note: external requirements
101103
--> $DIR/projection-no-regions-closure.rs:52:23

src/test/ui/nll/ty-outlives/projection-no-regions-fn.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | Box::new(x.next())
55
| ^^^^^^^^^^^^^^^^^^
66
|
77
= help: consider adding an explicit lifetime bound `<T as Iterator>::Item: 'a`...
8+
= note: ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds
89

910
error[E0309]: the associated type `<T as Iterator>::Item` may not live long enough
1011
--> $DIR/projection-no-regions-fn.rs:28:5
@@ -13,6 +14,7 @@ LL | Box::new(x.next())
1314
| ^^^^^^^^^^^^^^^^^^
1415
|
1516
= help: consider adding an explicit lifetime bound `<T as Iterator>::Item: 'a`...
17+
= note: ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds
1618

1719
error: aborting due to 2 previous errors
1820

src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ LL | fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
3535
| - help: consider adding an explicit lifetime bound...: `T: 'a`
3636
...
3737
LL | with_signature(cell, t, |cell, t| require(cell, t));
38-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
38+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
3939

4040
error: lifetime may not live long enough
4141
--> $DIR/projection-one-region-closure.rs:45:39
@@ -86,7 +86,7 @@ LL | fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
8686
| - help: consider adding an explicit lifetime bound...: `T: 'a`
8787
...
8888
LL | with_signature(cell, t, |cell, t| require(cell, t));
89-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
89+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
9090

9191
error: lifetime may not live long enough
9292
--> $DIR/projection-one-region-closure.rs:56:39

src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
3434
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
3535
|
3636
= help: consider adding an explicit lifetime bound `<T as Anything<ReEarlyBound(0, 'b), ReEarlyBound(1, 'c)>>::AssocType: 'a`...
37+
= note: ...so that the type `<T as Anything<ReEarlyBound(0, 'b), ReEarlyBound(1, 'c)>>::AssocType` will meet its required lifetime bounds
3738

3839
note: external requirements
3940
--> $DIR/projection-two-region-trait-bound-closure.rs:48:29
@@ -70,6 +71,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
7071
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
7172
|
7273
= help: consider adding an explicit lifetime bound `<T as Anything<ReEarlyBound(1, 'b), ReEarlyBound(2, 'c)>>::AssocType: 'a`...
74+
= note: ...so that the type `<T as Anything<ReEarlyBound(1, 'b), ReEarlyBound(2, 'c)>>::AssocType` will meet its required lifetime bounds
7375

7476
note: external requirements
7577
--> $DIR/projection-two-region-trait-bound-closure.rs:61:29

src/test/ui/nll/ty-outlives/projection-where-clause-none.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | fn foo<'a, T>() -> &'a ()
55
| - help: consider adding an explicit lifetime bound...: `T: 'a`
66
...
77
LL | bar::<T::Output>()
8-
| ^^^^^^^^^^^^^^^^
8+
| ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
99

1010
error: aborting due to previous error
1111

src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ error[E0309]: the parameter type `T` may not live long enough
5555
LL | fn generic_fail<'a, T>(cell: Cell<&'a ()>, value: T) {
5656
| - help: consider adding an explicit lifetime bound...: `T: 'a`
5757
LL | twice(cell, value, |a, b| invoke(a, b));
58-
| ^^^^^^^^^^^^^^^^^^^
58+
| ^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
5959

6060
error: aborting due to previous error
6161

src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ LL | fn no_region<'a, T>(x: Box<T>) -> Box<dyn Debug + 'a>
3333
| - help: consider adding an explicit lifetime bound...: `T: 'a`
3434
...
3535
LL | with_signature(x, |y| y)
36-
| ^^^^^
36+
| ^^^^^ ...so that the type `T` will meet its required lifetime bounds
3737

3838
error[E0309]: the parameter type `T` may not live long enough
3939
--> $DIR/ty-param-closure-outlives-from-return-type.rs:41:5
@@ -42,7 +42,7 @@ LL | fn wrong_region<'a, 'b, T>(x: Box<T>) -> Box<Debug + 'a>
4242
| - help: consider adding an explicit lifetime bound...: `T: 'a`
4343
...
4444
LL | x
45-
| ^
45+
| ^ ...so that the type `T` will meet its required lifetime bounds
4646

4747
error: aborting due to 2 previous errors
4848

src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ LL | | // See `correct_region`, which explains the point of this
4747
... |
4848
LL | | require(&x, &y)
4949
LL | | })
50-
| |_____^
50+
| |_____^ ...so that the type `T` will meet its required lifetime bounds
5151

5252
note: external requirements
5353
--> $DIR/ty-param-closure-outlives-from-where-clause.rs:43:26
@@ -130,7 +130,7 @@ LL | |
130130
LL | | // See `correct_region`
131131
LL | | require(&x, &y)
132132
LL | | })
133-
| |_____^
133+
| |_____^ ...so that the type `T` will meet its required lifetime bounds
134134

135135
note: external requirements
136136
--> $DIR/ty-param-closure-outlives-from-where-clause.rs:77:26

src/test/ui/nll/ty-outlives/ty-param-fn-body.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0309]: the parameter type `T` may not live long enough
44
LL | fn region_static<'a, T>(cell: Cell<&'a usize>, t: T) {
55
| - help: consider adding an explicit lifetime bound...: `T: 'a`
66
LL | outlives(cell, t)
7-
| ^^^^^^^^^^^^^^^^^
7+
| ^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
88

99
error: aborting due to previous error
1010

src/test/ui/nll/ty-outlives/ty-param-fn.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | fn no_region<'a, T>(x: Box<T>) -> Box<Debug + 'a>
55
| - help: consider adding an explicit lifetime bound...: `T: 'a`
66
...
77
LL | x
8-
| ^
8+
| ^ ...so that the type `T` will meet its required lifetime bounds
99

1010
error[E0309]: the parameter type `T` may not live long enough
1111
--> $DIR/ty-param-fn.rs:26:5
@@ -14,7 +14,7 @@ LL | fn wrong_region<'a, 'b, T>(x: Box<T>) -> Box<Debug + 'a>
1414
| - help: consider adding an explicit lifetime bound...: `T: 'a`
1515
...
1616
LL | x
17-
| ^
17+
| ^ ...so that the type `T` will meet its required lifetime bounds
1818

1919
error: aborting due to 2 previous errors
2020

src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.nll.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ error[E0310]: the parameter type `T` may not live long enough
2222
LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
2323
| - help: consider adding an explicit lifetime bound...: `T: 'static`
2424
LL | t
25-
| ^
25+
| ^ ...so that the type `T` will meet its required lifetime bounds
2626

2727
error: aborting due to 3 previous errors
2828

0 commit comments

Comments
 (0)