small tweaks
This commit is contained in:
parent
34d8692262
commit
e31367de6b
@ -79,15 +79,22 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
);
|
||||
} else {
|
||||
err.span_label(sup_origin.span(), "...is captured here...");
|
||||
err.span_note(
|
||||
return_sp,
|
||||
"...and is required to live as long as `'static` here",
|
||||
);
|
||||
if return_sp < sup_origin.span() {
|
||||
err.span_note(
|
||||
return_sp,
|
||||
"...and is required to live as long as `'static` here",
|
||||
);
|
||||
} else {
|
||||
err.span_label(
|
||||
return_sp,
|
||||
"...and is required to live as long as `'static` here",
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
err.span_label(
|
||||
return_sp,
|
||||
"...is captured and required live as long as `'static` here",
|
||||
"...is captured and required to live as long as `'static` here",
|
||||
);
|
||||
}
|
||||
|
||||
@ -104,7 +111,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
};
|
||||
let explicit =
|
||||
format!("you can add an explicit `{}` lifetime bound", lifetime_name);
|
||||
let explicit_static = format!("explicit `'static` bound to {}", arg);
|
||||
let explicit_static =
|
||||
format!("explicit `'static` bound to the lifetime of {}", arg);
|
||||
let captures = format!("captures data from {}", arg);
|
||||
let add_static_bound =
|
||||
"alternatively, add an explicit `'static` bound to this reference";
|
||||
|
@ -6,12 +6,8 @@ LL | pub async fn run_dummy_fn(&self) {
|
||||
| |
|
||||
| this data with an anonymous lifetime `'_`...
|
||||
| ...is captured here...
|
||||
|
|
||||
note: ...and is required to live as long as `'static` here
|
||||
--> $DIR/issue-62097.rs:13:9
|
||||
|
|
||||
LL | foo(|| self.bar()).await;
|
||||
| ^^^
|
||||
| --- ...and is required to live as long as `'static` here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -47,7 +47,7 @@ note: ...and is required to live as long as `'static` here
|
||||
|
|
||||
LL | fn elided2(x: &i32) -> impl Copy + 'static { x }
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
help: consider changing the `impl Trait`'s explicit `'static` bound to argument `x`
|
||||
help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x`
|
||||
|
|
||||
LL | fn elided2(x: &i32) -> impl Copy + '_ { x }
|
||||
| ^^
|
||||
@ -69,7 +69,7 @@ note: ...and is required to live as long as `'static` here
|
||||
|
|
||||
LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x }
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
help: consider changing the `impl Trait`'s explicit `'static` bound to argument `x`
|
||||
help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x`
|
||||
|
|
||||
LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'a { x }
|
||||
| ^^
|
||||
@ -97,7 +97,7 @@ note: ...and is required to live as long as `'static` here
|
||||
|
|
||||
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: consider changing the `impl Trait`'s explicit `'static` bound to argument `x`
|
||||
help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x`
|
||||
|
|
||||
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'a { x }
|
||||
| ^^
|
||||
@ -157,7 +157,7 @@ LL | fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) }
|
||||
| |
|
||||
| this data with an anonymous lifetime `'_`...
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to argument `x`
|
||||
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x`
|
||||
|
|
||||
LL | fn elided4(x: &i32) -> Box<dyn Debug + '_> { Box::new(x) }
|
||||
| ^^
|
||||
@ -172,7 +172,7 @@ error[E0758]: cannot infer an appropriate lifetime
|
||||
LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'static> { Box::new(x) }
|
||||
| ------- this data with lifetime `'a`... ^ ...is captured here, requiring it to live as long as `'static`
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to argument `x`
|
||||
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x`
|
||||
|
|
||||
LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'a> { Box::new(x) }
|
||||
| ^^
|
||||
|
@ -5,7 +5,7 @@ LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> {
|
||||
| --------------- this data with an anonymous lifetime `'_`...
|
||||
...
|
||||
LL | ss.r
|
||||
| ^^^^ ...is captured and required live as long as `'static` here
|
||||
| ^^^^ ...is captured and required to live as long as `'static` here
|
||||
|
|
||||
help: to declare that the trait object captures data from argument `ss`, you can add an explicit `'_` lifetime bound
|
||||
|
|
||||
|
@ -6,7 +6,7 @@ LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> {
|
||||
LL | let x: Box<dyn Foo + 'static> = Box::new(v);
|
||||
| ^ ...is captured here, requiring it to live as long as `'static`
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to argument `v`
|
||||
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
|
||||
|
|
||||
LL | fn a(v: &[u8]) -> Box<dyn Foo + '_> {
|
||||
| ^^
|
||||
@ -23,7 +23,7 @@ LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
|
||||
LL | Box::new(v)
|
||||
| ^ ...is captured here, requiring it to live as long as `'static`
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to argument `v`
|
||||
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
|
||||
|
|
||||
LL | fn b(v: &[u8]) -> Box<dyn Foo + '_> {
|
||||
| ^^
|
||||
|
@ -6,7 +6,7 @@ LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'static> {
|
||||
LL | box B(&*v) as Box<dyn X>
|
||||
| ^^^ ...is captured here, requiring it to live as long as `'static`
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to argument `v`
|
||||
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
|
||||
|
|
||||
LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'a> {
|
||||
| ^^
|
||||
|
@ -6,7 +6,7 @@ LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> {
|
||||
LL | box B(&*v) as Box<dyn X>
|
||||
| ^^^ ...is captured here, requiring it to live as long as `'static`
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to argument `v`
|
||||
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
|
||||
|
|
||||
LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'a> {
|
||||
| ^^
|
||||
|
@ -7,7 +7,7 @@ LL | // This is illegal, because the region bound on `proc` is 'static.
|
||||
LL | Box::new(move || { *x })
|
||||
| ^^^^^^^^^^^^^^ ...is captured here, requiring it to live as long as `'static`
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to argument `x`
|
||||
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x`
|
||||
|
|
||||
LL | fn static_proc(x: &isize) -> Box<dyn FnMut() -> (isize) + '_> {
|
||||
| ^^
|
||||
|
@ -2,15 +2,10 @@ error[E0758]: cannot infer an appropriate lifetime
|
||||
--> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:8:16
|
||||
|
|
||||
LL | async fn f(self: Pin<&Self>) -> impl Clone { self }
|
||||
| ^^^^ ---------- this data with an anonymous lifetime `'_`...
|
||||
| |
|
||||
| ^^^^ ---------- ---------- ...and is required to live as long as `'static` here
|
||||
| | |
|
||||
| | this data with an anonymous lifetime `'_`...
|
||||
| ...is captured here...
|
||||
|
|
||||
note: ...and is required to live as long as `'static` here
|
||||
--> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:8:37
|
||||
|
|
||||
LL | async fn f(self: Pin<&Self>) -> impl Clone { self }
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
|
||||
| ---- this data with an anonymous lifetime `'_`...
|
||||
LL | // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`
|
||||
LL | Box::new(items.iter())
|
||||
| ---------------^^^^--- ...is captured and required live as long as `'static` here
|
||||
| ---------------^^^^--- ...is captured and required to live as long as `'static` here
|
||||
|
|
||||
help: to declare that the trait object captures data from argument `items`, you can add an explicit `'_` lifetime bound
|
||||
|
|
||||
|
Loading…
x
Reference in New Issue
Block a user