1
Fork 0

Recover missing suggestion part under NLL

This commit is contained in:
marmeladema 2022-04-24 09:36:23 +02:00
parent 7b0db3e7c8
commit 53120b59ae
15 changed files with 26 additions and 17 deletions

View file

@ -4,6 +4,7 @@ use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed
use rustc_infer::infer::{ use rustc_infer::infer::{
error_reporting::nice_region_error::NiceRegionError, error_reporting::nice_region_error::NiceRegionError,
error_reporting::unexpected_hidden_region_diagnostic, NllRegionVariableOrigin, error_reporting::unexpected_hidden_region_diagnostic, NllRegionVariableOrigin,
RelateParamBound,
}; };
use rustc_middle::hir::place::PlaceBase; use rustc_middle::hir::place::PlaceBase;
use rustc_middle::mir::{ConstraintCategory, ReturnConstraint}; 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); let type_test_span = type_test.locations.span(&self.body);
if let Some(lower_bound_region) = lower_bound_region { 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( self.buffer_error(self.infcx.construct_generic_bound_failure(
type_test_span, type_test_span,
None, Some(origin),
type_test.generic_kind, type_test.generic_kind,
lower_bound_region, lower_bound_region,
self.body.source.def_id().as_local(), self.body.source.def_id().as_local(),

View file

@ -47,7 +47,7 @@ LL | | // This function call requires that
... | ... |
LL | | require(value); LL | | require(value);
LL | | }); LL | | });
| |_____^ | |_____^ ...so that the type `T` will meet its required lifetime bounds
error: aborting due to previous error error: aborting due to previous error

View file

@ -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` | - help: consider adding an explicit lifetime bound...: `T: 'a`
... ...
LL | x LL | x
| ^ | ^ ...so that the type `T` will meet its required lifetime bounds
error[E0309]: the parameter type `T` may not live long enough error[E0309]: the parameter type `T` may not live long enough
--> $DIR/impl-trait-outlives.rs:26:5 --> $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` | - help: consider adding an explicit lifetime bound...: `T: 'a`
... ...
LL | x LL | x
| ^ | ^ ...so that the type `T` will meet its required lifetime bounds
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -4,7 +4,7 @@ error[E0310]: the parameter type `T` may not live long enough
LL | fn generic2<T: Iterator>(value: T) { LL | fn generic2<T: Iterator>(value: T) {
| -- help: consider adding an explicit lifetime bound...: `T: 'static +` | -- help: consider adding an explicit lifetime bound...: `T: 'static +`
LL | twice(value, |value_ref, item| invoke2(value_ref, item)); 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 error: aborting due to previous error

View file

@ -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`... = 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 note: external requirements
--> $DIR/projection-no-regions-closure.rs:34:23 --> $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`... = 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 note: external requirements
--> $DIR/projection-no-regions-closure.rs:52:23 --> $DIR/projection-no-regions-closure.rs:52:23

View file

@ -5,6 +5,7 @@ LL | Box::new(x.next())
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
| |
= help: consider adding an explicit lifetime bound `<T as Iterator>::Item: 'a`... = 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 error[E0309]: the associated type `<T as Iterator>::Item` may not live long enough
--> $DIR/projection-no-regions-fn.rs:28:5 --> $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`... = 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 error: aborting due to 2 previous errors

View file

@ -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` | - help: consider adding an explicit lifetime bound...: `T: 'a`
... ...
LL | with_signature(cell, t, |cell, t| require(cell, t)); 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 error: lifetime may not live long enough
--> $DIR/projection-one-region-closure.rs:45:39 --> $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` | - help: consider adding an explicit lifetime bound...: `T: 'a`
... ...
LL | with_signature(cell, t, |cell, t| require(cell, t)); 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 error: lifetime may not live long enough
--> $DIR/projection-one-region-closure.rs:56:39 --> $DIR/projection-one-region-closure.rs:56:39

View file

@ -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`... = 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 note: external requirements
--> $DIR/projection-two-region-trait-bound-closure.rs:48:29 --> $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`... = 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 note: external requirements
--> $DIR/projection-two-region-trait-bound-closure.rs:61:29 --> $DIR/projection-two-region-trait-bound-closure.rs:61:29

View file

@ -5,7 +5,7 @@ LL | fn foo<'a, T>() -> &'a ()
| - help: consider adding an explicit lifetime bound...: `T: 'a` | - help: consider adding an explicit lifetime bound...: `T: 'a`
... ...
LL | bar::<T::Output>() LL | bar::<T::Output>()
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
error: aborting due to previous error error: aborting due to previous error

View file

@ -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) { LL | fn generic_fail<'a, T>(cell: Cell<&'a ()>, value: T) {
| - help: consider adding an explicit lifetime bound...: `T: 'a` | - help: consider adding an explicit lifetime bound...: `T: 'a`
LL | twice(cell, value, |a, b| invoke(a, b)); 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 error: aborting due to previous error

View file

@ -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` | - help: consider adding an explicit lifetime bound...: `T: 'a`
... ...
LL | with_signature(x, |y| y) 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 error[E0309]: the parameter type `T` may not live long enough
--> $DIR/ty-param-closure-outlives-from-return-type.rs:41:5 --> $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` | - help: consider adding an explicit lifetime bound...: `T: 'a`
... ...
LL | x LL | x
| ^ | ^ ...so that the type `T` will meet its required lifetime bounds
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -47,7 +47,7 @@ LL | | // See `correct_region`, which explains the point of this
... | ... |
LL | | require(&x, &y) LL | | require(&x, &y)
LL | | }) LL | | })
| |_____^ | |_____^ ...so that the type `T` will meet its required lifetime bounds
note: external requirements note: external requirements
--> $DIR/ty-param-closure-outlives-from-where-clause.rs:43:26 --> $DIR/ty-param-closure-outlives-from-where-clause.rs:43:26
@ -130,7 +130,7 @@ LL | |
LL | | // See `correct_region` LL | | // See `correct_region`
LL | | require(&x, &y) LL | | require(&x, &y)
LL | | }) LL | | })
| |_____^ | |_____^ ...so that the type `T` will meet its required lifetime bounds
note: external requirements note: external requirements
--> $DIR/ty-param-closure-outlives-from-where-clause.rs:77:26 --> $DIR/ty-param-closure-outlives-from-where-clause.rs:77:26

View file

@ -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) { LL | fn region_static<'a, T>(cell: Cell<&'a usize>, t: T) {
| - help: consider adding an explicit lifetime bound...: `T: 'a` | - help: consider adding an explicit lifetime bound...: `T: 'a`
LL | outlives(cell, t) LL | outlives(cell, t)
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
error: aborting due to previous error error: aborting due to previous error

View file

@ -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` | - help: consider adding an explicit lifetime bound...: `T: 'a`
... ...
LL | x LL | x
| ^ | ^ ...so that the type `T` will meet its required lifetime bounds
error[E0309]: the parameter type `T` may not live long enough error[E0309]: the parameter type `T` may not live long enough
--> $DIR/ty-param-fn.rs:26:5 --> $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` | - help: consider adding an explicit lifetime bound...: `T: 'a`
... ...
LL | x LL | x
| ^ | ^ ...so that the type `T` will meet its required lifetime bounds
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -22,7 +22,7 @@ error[E0310]: the parameter type `T` may not live long enough
LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> { LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
| - help: consider adding an explicit lifetime bound...: `T: 'static` | - help: consider adding an explicit lifetime bound...: `T: 'static`
LL | t LL | t
| ^ | ^ ...so that the type `T` will meet its required lifetime bounds
error: aborting due to 3 previous errors error: aborting due to 3 previous errors