Add indication of anonymous lifetime position
This commit is contained in:
parent
fece59b56c
commit
17176ccd78
|
@ -50,6 +50,7 @@ use super::region_constraints::GenericKind;
|
|||
use super::{InferCtxt, RegionVariableOrigin, SubregionOrigin, TypeTrace, ValuePairs};
|
||||
|
||||
use crate::infer;
|
||||
use crate::infer::error_reporting::nice_region_error::find_anon_type::find_anon_type;
|
||||
use crate::traits::error_reporting::report_object_safety_error;
|
||||
use crate::traits::{
|
||||
IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode,
|
||||
|
@ -179,7 +180,14 @@ fn msg_span_from_early_bound_and_free_regions(
|
|||
}
|
||||
ty::ReFree(ref fr) => match fr.bound_region {
|
||||
ty::BrAnon(idx) => {
|
||||
(format!("the anonymous lifetime #{} defined on", idx + 1), tcx.hir().span(node))
|
||||
if let Some((ty, _)) = find_anon_type(tcx, region, &fr.bound_region) {
|
||||
("the anonymous lifetime defined on".to_string(), ty.span)
|
||||
} else {
|
||||
(
|
||||
format!("the anonymous lifetime #{} defined on", idx + 1),
|
||||
tcx.hir().span(node),
|
||||
)
|
||||
}
|
||||
}
|
||||
_ => (
|
||||
format!("the lifetime `{}` as defined on", region),
|
||||
|
|
|
@ -7,11 +7,11 @@ LL | | t.test();
|
|||
LL | | });
|
||||
| |______^
|
||||
|
|
||||
note: the parameter type `T` must be valid for the anonymous lifetime #2 defined on the function body at 19:1...
|
||||
--> $DIR/missing-lifetimes-in-signature-2.rs:19:1
|
||||
note: the parameter type `T` must be valid for the anonymous lifetime defined on the function body at 19:24...
|
||||
--> $DIR/missing-lifetimes-in-signature-2.rs:19:24
|
||||
|
|
||||
LL | fn func<T: Test>(foo: &Foo, t: T) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@ LL | fn func<T: Test>(foo: &Foo, t: T) {
|
|||
LL | foo.bar(move |_| {
|
||||
| ^^^
|
||||
|
|
||||
note: the parameter type `T` must be valid for the anonymous lifetime #2 defined on the function body at 19:1...
|
||||
--> $DIR/missing-lifetimes-in-signature-2.rs:19:1
|
||||
note: the parameter type `T` must be valid for the anonymous lifetime defined on the function body at 19:24...
|
||||
--> $DIR/missing-lifetimes-in-signature-2.rs:19:24
|
||||
|
|
||||
LL | fn func<T: Test>(foo: &Foo, t: T) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^
|
||||
note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature-2.rs:20:13: 23:6]` will meet its required lifetime bounds
|
||||
--> $DIR/missing-lifetimes-in-signature-2.rs:20:9
|
||||
|
|
||||
|
|
|
@ -25,14 +25,11 @@ error[E0311]: the parameter type `G` may not live long enough
|
|||
LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the function body at 25:1...
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:25:1
|
||||
note: the parameter type `G` must be valid for the anonymous lifetime defined on the function body at 25:26...
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:25:26
|
||||
|
|
||||
LL | / fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
LL | |
|
||||
LL | | where
|
||||
LL | | G: Get<T>
|
||||
| |_____________^
|
||||
LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
| ^^^^^^
|
||||
|
||||
error[E0311]: the parameter type `G` may not live long enough
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:47:45
|
||||
|
@ -40,14 +37,11 @@ error[E0311]: the parameter type `G` may not live long enough
|
|||
LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the function body at 47:1...
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:47:1
|
||||
note: the parameter type `G` must be valid for the anonymous lifetime defined on the function body at 47:34...
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:47:34
|
||||
|
|
||||
LL | / fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
LL | |
|
||||
LL | | where
|
||||
LL | | G: Get<T>
|
||||
| |_____________^
|
||||
LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
| ^^^^^^
|
||||
|
||||
error[E0311]: the parameter type `G` may not live long enough
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:59:58
|
||||
|
@ -55,11 +49,11 @@ error[E0311]: the parameter type `G` may not live long enough
|
|||
LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the method body at 59:5...
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:59:5
|
||||
note: the parameter type `G` must be valid for the anonymous lifetime defined on the method body at 59:47...
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:59:47
|
||||
|
|
||||
LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^
|
||||
|
||||
error[E0311]: the parameter type `G` may not live long enough
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:68:45
|
||||
|
@ -67,14 +61,11 @@ error[E0311]: the parameter type `G` may not live long enough
|
|||
LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the function body at 68:1...
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:68:1
|
||||
note: the parameter type `G` must be valid for the anonymous lifetime defined on the function body at 68:34...
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:68:34
|
||||
|
|
||||
LL | / fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
|
||||
LL | |
|
||||
LL | | where
|
||||
LL | | G: Get<T>
|
||||
| |_____________^
|
||||
LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
|
||||
| ^^^^^^
|
||||
|
||||
error[E0621]: explicit lifetime required in the type of `dest`
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:73:5
|
||||
|
|
|
@ -33,14 +33,11 @@ error[E0311]: the parameter type `G` may not live long enough
|
|||
LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the function body at 25:1...
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:25:1
|
||||
note: the parameter type `G` must be valid for the anonymous lifetime defined on the function body at 25:26...
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:25:26
|
||||
|
|
||||
LL | / fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
LL | |
|
||||
LL | | where
|
||||
LL | | G: Get<T>
|
||||
| |_____________^
|
||||
LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
| ^^^^^^
|
||||
note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:30:5: 32:6]` will meet its required lifetime bounds
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:25:37
|
||||
|
|
||||
|
@ -57,14 +54,11 @@ error[E0311]: the parameter type `G` may not live long enough
|
|||
LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the function body at 47:1...
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:47:1
|
||||
note: the parameter type `G` must be valid for the anonymous lifetime defined on the function body at 47:34...
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:47:34
|
||||
|
|
||||
LL | / fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
LL | |
|
||||
LL | | where
|
||||
LL | | G: Get<T>
|
||||
| |_____________^
|
||||
LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
| ^^^^^^
|
||||
note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:52:5: 54:6]` will meet its required lifetime bounds
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:47:45
|
||||
|
|
||||
|
@ -81,11 +75,11 @@ error[E0311]: the parameter type `G` may not live long enough
|
|||
LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the method body at 59:5...
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:59:5
|
||||
note: the parameter type `G` must be valid for the anonymous lifetime defined on the method body at 59:47...
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:59:47
|
||||
|
|
||||
LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^
|
||||
note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:61:9: 63:10]` will meet its required lifetime bounds
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:59:58
|
||||
|
|
||||
|
|
Loading…
Reference in New Issue