Recover missing suggestion part under NLL
This commit is contained in:
parent
7b0db3e7c8
commit
53120b59ae
15 changed files with 26 additions and 17 deletions
|
@ -4,6 +4,7 @@ use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed
|
|||
use rustc_infer::infer::{
|
||||
error_reporting::nice_region_error::NiceRegionError,
|
||||
error_reporting::unexpected_hidden_region_diagnostic, NllRegionVariableOrigin,
|
||||
RelateParamBound,
|
||||
};
|
||||
use rustc_middle::hir::place::PlaceBase;
|
||||
use rustc_middle::mir::{ConstraintCategory, ReturnConstraint};
|
||||
|
@ -166,9 +167,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
let type_test_span = type_test.locations.span(&self.body);
|
||||
|
||||
if let Some(lower_bound_region) = lower_bound_region {
|
||||
let generic_ty = type_test.generic_kind.to_ty(self.infcx.tcx);
|
||||
let origin = RelateParamBound(type_test_span, generic_ty, None);
|
||||
self.buffer_error(self.infcx.construct_generic_bound_failure(
|
||||
type_test_span,
|
||||
None,
|
||||
Some(origin),
|
||||
type_test.generic_kind,
|
||||
lower_bound_region,
|
||||
self.body.source.def_id().as_local(),
|
||||
|
|
|
@ -47,7 +47,7 @@ LL | | // This function call requires that
|
|||
... |
|
||||
LL | | require(value);
|
||||
LL | | });
|
||||
| |_____^
|
||||
| |_____^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ LL | fn no_region<'a, T>(x: Box<T>) -> impl Debug + 'a
|
|||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
...
|
||||
LL | x
|
||||
| ^
|
||||
| ^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/impl-trait-outlives.rs:26:5
|
||||
|
@ -14,7 +14,7 @@ LL | fn wrong_region<'a, 'b, T>(x: Box<T>) -> impl Debug + 'a
|
|||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
...
|
||||
LL | x
|
||||
| ^
|
||||
| ^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ error[E0310]: the parameter type `T` may not live long enough
|
|||
LL | fn generic2<T: Iterator>(value: T) {
|
||||
| -- help: consider adding an explicit lifetime bound...: `T: 'static +`
|
||||
LL | twice(value, |value_ref, item| invoke2(value_ref, item));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ LL | with_signature(x, |mut y| Box::new(y.next()))
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `<T as Iterator>::Item: 'a`...
|
||||
= note: ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds
|
||||
|
||||
note: external requirements
|
||||
--> $DIR/projection-no-regions-closure.rs:34:23
|
||||
|
@ -96,6 +97,7 @@ LL | with_signature(x, |mut y| Box::new(y.next()))
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `<T as Iterator>::Item: 'a`...
|
||||
= note: ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds
|
||||
|
||||
note: external requirements
|
||||
--> $DIR/projection-no-regions-closure.rs:52:23
|
||||
|
|
|
@ -5,6 +5,7 @@ LL | Box::new(x.next())
|
|||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `<T as Iterator>::Item: 'a`...
|
||||
= note: ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds
|
||||
|
||||
error[E0309]: the associated type `<T as Iterator>::Item` may not live long enough
|
||||
--> $DIR/projection-no-regions-fn.rs:28:5
|
||||
|
@ -13,6 +14,7 @@ LL | Box::new(x.next())
|
|||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `<T as Iterator>::Item: 'a`...
|
||||
= note: ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ LL | fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
|
|||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
...
|
||||
LL | with_signature(cell, t, |cell, t| require(cell, t));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $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)
|
|||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
...
|
||||
LL | with_signature(cell, t, |cell, t| require(cell, t));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/projection-one-region-closure.rs:56:39
|
||||
|
|
|
@ -34,6 +34,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `<T as Anything<ReEarlyBound(0, 'b), ReEarlyBound(1, 'c)>>::AssocType: 'a`...
|
||||
= note: ...so that the type `<T as Anything<ReEarlyBound(0, 'b), ReEarlyBound(1, 'c)>>::AssocType` will meet its required lifetime bounds
|
||||
|
||||
note: external requirements
|
||||
--> $DIR/projection-two-region-trait-bound-closure.rs:48:29
|
||||
|
@ -70,6 +71,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `<T as Anything<ReEarlyBound(1, 'b), ReEarlyBound(2, 'c)>>::AssocType: 'a`...
|
||||
= note: ...so that the type `<T as Anything<ReEarlyBound(1, 'b), ReEarlyBound(2, 'c)>>::AssocType` will meet its required lifetime bounds
|
||||
|
||||
note: external requirements
|
||||
--> $DIR/projection-two-region-trait-bound-closure.rs:61:29
|
||||
|
|
|
@ -5,7 +5,7 @@ LL | fn foo<'a, T>() -> &'a ()
|
|||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
...
|
||||
LL | bar::<T::Output>()
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
|||
LL | fn generic_fail<'a, T>(cell: Cell<&'a ()>, value: T) {
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
LL | twice(cell, value, |a, b| invoke(a, b));
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ LL | fn no_region<'a, T>(x: Box<T>) -> Box<dyn Debug + 'a>
|
|||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
...
|
||||
LL | with_signature(x, |y| y)
|
||||
| ^^^^^
|
||||
| ^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $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>
|
|||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
...
|
||||
LL | x
|
||||
| ^
|
||||
| ^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ LL | | // See `correct_region`, which explains the point of this
|
|||
... |
|
||||
LL | | require(&x, &y)
|
||||
LL | | })
|
||||
| |_____^
|
||||
| |_____^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
note: external requirements
|
||||
--> $DIR/ty-param-closure-outlives-from-where-clause.rs:43:26
|
||||
|
@ -130,7 +130,7 @@ LL | |
|
|||
LL | | // See `correct_region`
|
||||
LL | | require(&x, &y)
|
||||
LL | | })
|
||||
| |_____^
|
||||
| |_____^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
note: external requirements
|
||||
--> $DIR/ty-param-closure-outlives-from-where-clause.rs:77:26
|
||||
|
|
|
@ -4,7 +4,7 @@ error[E0309]: the parameter type `T` may not live long enough
|
|||
LL | fn region_static<'a, T>(cell: Cell<&'a usize>, t: T) {
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
LL | outlives(cell, t)
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ LL | fn no_region<'a, T>(x: Box<T>) -> Box<Debug + 'a>
|
|||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
...
|
||||
LL | x
|
||||
| ^
|
||||
| ^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/ty-param-fn.rs:26:5
|
||||
|
@ -14,7 +14,7 @@ LL | fn wrong_region<'a, 'b, T>(x: Box<T>) -> Box<Debug + 'a>
|
|||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
...
|
||||
LL | x
|
||||
| ^
|
||||
| ^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ error[E0310]: the parameter type `T` may not live long enough
|
|||
LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
LL | t
|
||||
| ^
|
||||
| ^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue