review comments: wording
This commit is contained in:
parent
539e9783df
commit
31ea589a06
|
@ -75,18 +75,18 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
// | ---- ^
|
||||
err.span_label(
|
||||
sup_origin.span(),
|
||||
"...is captured here requiring it to live as long as `'static`",
|
||||
"...is captured here, requiring it to live as long as `'static`",
|
||||
);
|
||||
} else if sup_origin.span() <= return_sp {
|
||||
err.span_label(sup_origin.span(), "...is captured here...");
|
||||
err.span_label(
|
||||
return_sp,
|
||||
"...and required to live as long as `'static` by this",
|
||||
"...and is required to live as long as `'static` here",
|
||||
);
|
||||
} else {
|
||||
err.span_label(
|
||||
return_sp,
|
||||
"...is required to live as long as `'static` by this...",
|
||||
"...is required to live as long as `'static` here...",
|
||||
);
|
||||
err.span_label(sup_origin.span(), "...and is captured here");
|
||||
}
|
||||
|
@ -101,6 +101,20 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
// explicit non-desugar'able return.
|
||||
if fn_return.span.desugaring_kind().is_none() {
|
||||
// FIXME: account for the need of parens in `&(dyn Trait + '_)`
|
||||
|
||||
let consider = "consider changing the";
|
||||
let declare = "to declare that the";
|
||||
let arg = match param_info.param.pat.simple_ident() {
|
||||
Some(simple_ident) => format!("argument `{}`", simple_ident),
|
||||
None => "the argument".to_string(),
|
||||
};
|
||||
let explicit =
|
||||
format!("you can add an explicit `{}` lifetime bound", lifetime_name);
|
||||
let explicit_static = format!("explicit `'static` bound to {}", arg);
|
||||
let captures = format!("captures data from {}", arg);
|
||||
let add_static_bound =
|
||||
"alternatively, add an explicit `'static` bound to this reference";
|
||||
let plus_lt = format!(" + {}", lifetime_name);
|
||||
match fn_return.kind {
|
||||
TyKind::Def(item_id, _) => {
|
||||
let item = self.tcx().hir().item(item_id.id);
|
||||
|
@ -126,18 +140,13 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
{
|
||||
err.span_suggestion_verbose(
|
||||
span,
|
||||
&format!(
|
||||
"consider changing the `impl Trait`'s explicit \
|
||||
`'static` bound to {}",
|
||||
lifetime,
|
||||
),
|
||||
&format!("{} `impl Trait`'s {}", consider, explicit_static),
|
||||
lifetime_name,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
err.span_suggestion_verbose(
|
||||
param_info.param_ty_span,
|
||||
"alternatively, set an explicit `'static` lifetime to \
|
||||
this parameter",
|
||||
add_static_bound,
|
||||
param_info.param_ty.to_string(),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
|
@ -145,11 +154,12 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
err.span_suggestion_verbose(
|
||||
fn_return.span.shrink_to_hi(),
|
||||
&format!(
|
||||
"to permit non-static references in an `impl Trait` \
|
||||
value, you can add an explicit bound for {}",
|
||||
lifetime,
|
||||
"{declare} `impl Trait` {captures}, {explicit}",
|
||||
declare = declare,
|
||||
captures = captures,
|
||||
explicit = explicit,
|
||||
),
|
||||
format!(" + {}", lifetime_name),
|
||||
plus_lt,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
};
|
||||
|
@ -159,31 +169,25 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
err.span_suggestion_verbose(
|
||||
fn_return.span.shrink_to_hi(),
|
||||
&format!(
|
||||
"to permit non-static references in a trait object \
|
||||
value, you can add an explicit bound for {}",
|
||||
lifetime,
|
||||
"{declare} trait object {captures}, {explicit}",
|
||||
declare = declare,
|
||||
captures = captures,
|
||||
explicit = explicit,
|
||||
),
|
||||
format!(" + {}", lifetime_name),
|
||||
plus_lt,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
err.span_suggestion_verbose(
|
||||
lt.span,
|
||||
&format!(
|
||||
"consider changing the trait object's explicit \
|
||||
`'static` bound to {}",
|
||||
lifetime,
|
||||
),
|
||||
&format!("{} trait object's {}", consider, explicit_static),
|
||||
lifetime_name,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
err.span_suggestion_verbose(
|
||||
param_info.param_ty_span,
|
||||
&format!(
|
||||
"alternatively, set an explicit `'static` lifetime \
|
||||
in this parameter",
|
||||
),
|
||||
add_static_bound,
|
||||
param_info.param_ty.to_string(),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
|
|
|
@ -7,7 +7,7 @@ LL | pub async fn run_dummy_fn(&self) {
|
|||
| this data with an anonymous lifetime `'_`...
|
||||
| ...is captured here...
|
||||
LL | foo(|| self.bar()).await;
|
||||
| --- ...and required to live as long as `'static` by this
|
||||
| --- ...and is required to live as long as `'static` here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@ error[E0758]: cannot infer an appropriate lifetime
|
|||
LL | fn elided(x: &i32) -> impl Copy { x }
|
||||
| ---- --------- ^ ...and is captured here
|
||||
| | |
|
||||
| | ...is required to live as long as `'static` by this...
|
||||
| | ...is required to live as long as `'static` here...
|
||||
| this data with an anonymous lifetime `'_`...
|
||||
|
|
||||
help: to permit non-static references in an `impl Trait` value, you can add an explicit bound for an anonymous lifetime `'_`
|
||||
help: to declare that the `impl Trait` captures data from argument `x`, you can add an explicit `'_` lifetime bound
|
||||
|
|
||||
LL | fn elided(x: &i32) -> impl Copy + '_ { x }
|
||||
| ^^^^
|
||||
|
@ -18,10 +18,10 @@ error[E0758]: cannot infer an appropriate lifetime
|
|||
LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
|
||||
| ------- --------- ^ ...and is captured here
|
||||
| | |
|
||||
| | ...is required to live as long as `'static` by this...
|
||||
| | ...is required to live as long as `'static` here...
|
||||
| this data with lifetime `'a`...
|
||||
|
|
||||
help: to permit non-static references in an `impl Trait` value, you can add an explicit bound for lifetime `'a`
|
||||
help: to declare that the `impl Trait` captures data from argument `x`, you can add an explicit `'a` lifetime bound
|
||||
|
|
||||
LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x }
|
||||
| ^^^^
|
||||
|
@ -32,14 +32,14 @@ error[E0758]: cannot infer an appropriate lifetime
|
|||
LL | fn elided2(x: &i32) -> impl Copy + 'static { x }
|
||||
| ---- ------------------- ^ ...and is captured here
|
||||
| | |
|
||||
| | ...is required to live as long as `'static` by this...
|
||||
| | ...is required to live as long as `'static` here...
|
||||
| this data with an anonymous lifetime `'_`...
|
||||
|
|
||||
help: consider changing the `impl Trait`'s explicit `'static` bound to an anonymous lifetime `'_`
|
||||
help: consider changing the `impl Trait`'s explicit `'static` bound to argument `x`
|
||||
|
|
||||
LL | fn elided2(x: &i32) -> impl Copy + '_ { x }
|
||||
| ^^
|
||||
help: alternatively, set an explicit `'static` lifetime to this parameter
|
||||
help: alternatively, add an explicit `'static` bound to this reference
|
||||
|
|
||||
LL | fn elided2(x: &'static i32) -> impl Copy + 'static { x }
|
||||
| ^^^^^^^^^^^^
|
||||
|
@ -50,14 +50,14 @@ error[E0758]: cannot infer an appropriate lifetime
|
|||
LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x }
|
||||
| ------- ------------------- ^ ...and is captured here
|
||||
| | |
|
||||
| | ...is required to live as long as `'static` by this...
|
||||
| | ...is required to live as long as `'static` here...
|
||||
| this data with lifetime `'a`...
|
||||
|
|
||||
help: consider changing the `impl Trait`'s explicit `'static` bound to lifetime `'a`
|
||||
help: consider changing the `impl Trait`'s explicit `'static` bound to argument `x`
|
||||
|
|
||||
LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'a { x }
|
||||
| ^^
|
||||
help: alternatively, set an explicit `'static` lifetime to this parameter
|
||||
help: alternatively, add an explicit `'static` bound to this reference
|
||||
|
|
||||
LL | fn explicit2<'a>(x: &'static i32) -> impl Copy + 'static { x }
|
||||
| ^^^^^^^^^^^^
|
||||
|
@ -76,14 +76,14 @@ error[E0758]: cannot infer an appropriate lifetime
|
|||
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
|
||||
| ------- -------------------------------- ^ ...and is captured here
|
||||
| | |
|
||||
| | ...is required to live as long as `'static` by this...
|
||||
| | ...is required to live as long as `'static` here...
|
||||
| this data with lifetime `'a`...
|
||||
|
|
||||
help: consider changing the `impl Trait`'s explicit `'static` bound to lifetime `'a`
|
||||
help: consider changing the `impl Trait`'s explicit `'static` bound to argument `x`
|
||||
|
|
||||
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'a { x }
|
||||
| ^^
|
||||
help: alternatively, set an explicit `'static` lifetime to this parameter
|
||||
help: alternatively, add an explicit `'static` bound to this reference
|
||||
|
|
||||
LL | fn with_bound<'a>(x: &'static i32) -> impl LifetimeTrait<'a> + 'static { x }
|
||||
| ^^^^^^^^^^^^
|
||||
|
@ -109,11 +109,11 @@ error[E0758]: cannot infer an appropriate lifetime
|
|||
--> $DIR/must_outlive_least_region_or_bound.rs:18:50
|
||||
|
|
||||
LL | fn elided3(x: &i32) -> Box<dyn Debug> { Box::new(x) }
|
||||
| ---- ^ ...is captured here requiring it to live as long as `'static`
|
||||
| ---- ^ ...is captured here, requiring it to live as long as `'static`
|
||||
| |
|
||||
| this data with an anonymous lifetime `'_`...
|
||||
|
|
||||
help: to permit non-static references in a trait object value, you can add an explicit bound for an anonymous lifetime `'_`
|
||||
help: to declare that the trait object captures data from argument `x`, you can add an explicit `'_` lifetime bound
|
||||
|
|
||||
LL | fn elided3(x: &i32) -> Box<dyn Debug + '_> { Box::new(x) }
|
||||
| ^^^^
|
||||
|
@ -122,11 +122,11 @@ error[E0758]: cannot infer an appropriate lifetime
|
|||
--> $DIR/must_outlive_least_region_or_bound.rs:21:59
|
||||
|
|
||||
LL | fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug> { Box::new(x) }
|
||||
| ------- ^ ...is captured here requiring it to live as long as `'static`
|
||||
| ------- ^ ...is captured here, requiring it to live as long as `'static`
|
||||
| |
|
||||
| this data with lifetime `'a`...
|
||||
|
|
||||
help: to permit non-static references in a trait object value, you can add an explicit bound for lifetime `'a`
|
||||
help: to declare that the trait object captures data from argument `x`, you can add an explicit `'a` lifetime bound
|
||||
|
|
||||
LL | fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug + 'a> { Box::new(x) }
|
||||
| ^^^^
|
||||
|
@ -135,15 +135,15 @@ error[E0758]: cannot infer an appropriate lifetime
|
|||
--> $DIR/must_outlive_least_region_or_bound.rs:24:60
|
||||
|
|
||||
LL | fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) }
|
||||
| ---- ^ ...is captured here requiring it to live as long as `'static`
|
||||
| ---- ^ ...is captured here, requiring it to live as long as `'static`
|
||||
| |
|
||||
| this data with an anonymous lifetime `'_`...
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to an anonymous lifetime `'_`
|
||||
help: consider changing the trait object's explicit `'static` bound to argument `x`
|
||||
|
|
||||
LL | fn elided4(x: &i32) -> Box<dyn Debug + '_> { Box::new(x) }
|
||||
| ^^
|
||||
help: alternatively, set an explicit `'static` lifetime in this parameter
|
||||
help: alternatively, add an explicit `'static` bound to this reference
|
||||
|
|
||||
LL | fn elided4(x: &'static i32) -> Box<dyn Debug + 'static> { Box::new(x) }
|
||||
| ^^^^^^^^^^^^
|
||||
|
@ -152,13 +152,13 @@ error[E0758]: cannot infer an appropriate lifetime
|
|||
--> $DIR/must_outlive_least_region_or_bound.rs:27:69
|
||||
|
|
||||
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`
|
||||
| ------- 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 lifetime `'a`
|
||||
help: consider changing the trait object's explicit `'static` bound to argument `x`
|
||||
|
|
||||
LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'a> { Box::new(x) }
|
||||
| ^^
|
||||
help: alternatively, set an explicit `'static` lifetime in this parameter
|
||||
help: alternatively, add an explicit `'static` bound to this reference
|
||||
|
|
||||
LL | fn explicit4<'a>(x: &'static i32) -> Box<dyn Debug + 'static> { Box::new(x) }
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
|
@ -2,7 +2,7 @@ error[E0758]: cannot infer an appropriate lifetime
|
|||
--> $DIR/static-return-lifetime-infered.rs:7:16
|
||||
|
|
||||
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
|
||||
| ----- ----------------------- ...is required to live as long as `'static` by this...
|
||||
| ----- ----------------------- ...is required to live as long as `'static` here...
|
||||
| |
|
||||
| this data with an anonymous lifetime `'_`...
|
||||
LL | self.x.iter().map(|a| a.0)
|
||||
|
@ -10,7 +10,7 @@ LL | self.x.iter().map(|a| a.0)
|
|||
| |
|
||||
| ...and is captured here
|
||||
|
|
||||
help: to permit non-static references in an `impl Trait` value, you can add an explicit bound for an anonymous lifetime `'_`
|
||||
help: to declare that the `impl Trait` captures data from argument `self`, you can add an explicit `'_` lifetime bound
|
||||
|
|
||||
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ {
|
||||
| ^^^^
|
||||
|
@ -19,7 +19,7 @@ error[E0758]: cannot infer an appropriate lifetime
|
|||
--> $DIR/static-return-lifetime-infered.rs:11:16
|
||||
|
|
||||
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
|
||||
| -------- ----------------------- ...is required to live as long as `'static` by this...
|
||||
| -------- ----------------------- ...is required to live as long as `'static` here...
|
||||
| |
|
||||
| this data with lifetime `'a`...
|
||||
LL | self.x.iter().map(|a| a.0)
|
||||
|
@ -27,7 +27,7 @@ LL | self.x.iter().map(|a| a.0)
|
|||
| |
|
||||
| ...and is captured here
|
||||
|
|
||||
help: to permit non-static references in an `impl Trait` value, you can add an explicit bound for lifetime `'a`
|
||||
help: to declare that the `impl Trait` captures data from argument `self`, you can add an explicit `'a` lifetime bound
|
||||
|
|
||||
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> + 'a {
|
||||
| ^^^^
|
||||
|
|
|
@ -4,9 +4,9 @@ error[E0758]: cannot infer an appropriate lifetime
|
|||
LL | fn foo<T: Any>(value: &T) -> Box<dyn Any> {
|
||||
| -- this data with an anonymous lifetime `'_`...
|
||||
LL | Box::new(value) as Box<dyn Any>
|
||||
| ^^^^^ ...is captured here requiring it to live as long as `'static`
|
||||
| ^^^^^ ...is captured here, requiring it to live as long as `'static`
|
||||
|
|
||||
help: to permit non-static references in a trait object value, you can add an explicit bound for an anonymous lifetime `'_`
|
||||
help: to declare that the trait object captures data from argument `value`, you can add an explicit `'_` lifetime bound
|
||||
|
|
||||
LL | fn foo<T: Any>(value: &T) -> Box<dyn Any + '_> {
|
||||
| ^^^^
|
||||
|
|
|
@ -7,7 +7,7 @@ LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> {
|
|||
LL | ss.r
|
||||
| ^^^^ ...is captured and required live as long as `'static` here
|
||||
|
|
||||
help: to permit non-static references in a trait object value, you can add an explicit bound for an anonymous lifetime `'_`
|
||||
help: to declare that the trait object captures data from argument `ss`, you can add an explicit `'_` lifetime bound
|
||||
|
|
||||
LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait + '_> {
|
||||
| ^^^^
|
||||
|
|
|
@ -4,13 +4,13 @@ error[E0758]: cannot infer an appropriate lifetime
|
|||
LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> {
|
||||
| ----- this data with an anonymous lifetime `'_`...
|
||||
LL | let x: Box<dyn Foo + 'static> = Box::new(v);
|
||||
| ^ ...is captured here requiring it to live as long as `'static`
|
||||
| ^ ...is captured here, requiring it to live as long as `'static`
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to an anonymous lifetime `'_`
|
||||
help: consider changing the trait object's explicit `'static` bound to argument `v`
|
||||
|
|
||||
LL | fn a(v: &[u8]) -> Box<dyn Foo + '_> {
|
||||
| ^^
|
||||
help: alternatively, set an explicit `'static` lifetime in this parameter
|
||||
help: alternatively, add an explicit `'static` bound to this reference
|
||||
|
|
||||
LL | fn a(v: &'static [u8]) -> Box<dyn Foo + 'static> {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -21,13 +21,13 @@ error[E0758]: cannot infer an appropriate lifetime
|
|||
LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
|
||||
| ----- this data with an anonymous lifetime `'_`...
|
||||
LL | Box::new(v)
|
||||
| ^ ...is captured here requiring it to live as long as `'static`
|
||||
| ^ ...is captured here, requiring it to live as long as `'static`
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to an anonymous lifetime `'_`
|
||||
help: consider changing the trait object's explicit `'static` bound to argument `v`
|
||||
|
|
||||
LL | fn b(v: &[u8]) -> Box<dyn Foo + '_> {
|
||||
| ^^
|
||||
help: alternatively, set an explicit `'static` lifetime in this parameter
|
||||
help: alternatively, add an explicit `'static` bound to this reference
|
||||
|
|
||||
LL | fn b(v: &'static [u8]) -> Box<dyn Foo + 'static> {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -39,9 +39,9 @@ LL | fn c(v: &[u8]) -> Box<dyn Foo> {
|
|||
| ----- this data with an anonymous lifetime `'_`...
|
||||
...
|
||||
LL | Box::new(v)
|
||||
| ^ ...is captured here requiring it to live as long as `'static`
|
||||
| ^ ...is captured here, requiring it to live as long as `'static`
|
||||
|
|
||||
help: to permit non-static references in a trait object value, you can add an explicit bound for an anonymous lifetime `'_`
|
||||
help: to declare that the trait object captures data from argument `v`, you can add an explicit `'_` lifetime bound
|
||||
|
|
||||
LL | fn c(v: &[u8]) -> Box<dyn Foo + '_> {
|
||||
| ^^^^
|
||||
|
|
|
@ -4,13 +4,13 @@ error[E0758]: cannot infer an appropriate lifetime
|
|||
LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'static> {
|
||||
| ------------------ this data with lifetime `'a`...
|
||||
LL | box B(&*v) as Box<dyn X>
|
||||
| ^^^ ...is captured here requiring it to live as long as `'static`
|
||||
| ^^^ ...is captured here, requiring it to live as long as `'static`
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to lifetime `'a`
|
||||
help: consider changing the trait object's explicit `'static` bound to argument `v`
|
||||
|
|
||||
LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'a> {
|
||||
| ^^
|
||||
help: alternatively, set an explicit `'static` lifetime in this parameter
|
||||
help: alternatively, add an explicit `'static` bound to this reference
|
||||
|
|
||||
LL | fn g<'a, T: 'static>(v: std::boxed::Box<(dyn A<T> + 'static)>) -> Box<dyn X + 'static> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
@ -4,13 +4,13 @@ error[E0758]: cannot infer an appropriate lifetime
|
|||
LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> {
|
||||
| ---------------- this data with lifetime `'a`...
|
||||
LL | box B(&*v) as Box<dyn X>
|
||||
| ^^^ ...is captured here requiring it to live as long as `'static`
|
||||
| ^^^ ...is captured here, requiring it to live as long as `'static`
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to lifetime `'a`
|
||||
help: consider changing the trait object's explicit `'static` bound to argument `v`
|
||||
|
|
||||
LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'a> {
|
||||
| ^^
|
||||
help: alternatively, set an explicit `'static` lifetime in this parameter
|
||||
help: alternatively, add an explicit `'static` bound to this reference
|
||||
|
|
||||
LL | fn i<'a, T, U>(v: std::boxed::Box<(dyn A<U> + 'static)>) -> Box<dyn X + 'static> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
@ -5,13 +5,13 @@ LL | fn static_proc(x: &isize) -> Box<dyn FnMut() -> (isize) + 'static> {
|
|||
| ------ this data with an anonymous lifetime `'_`...
|
||||
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`
|
||||
| ^^^^^^^^^^^^^^ ...is captured here, requiring it to live as long as `'static`
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to an anonymous lifetime `'_`
|
||||
help: consider changing the trait object's explicit `'static` bound to argument `x`
|
||||
|
|
||||
LL | fn static_proc(x: &isize) -> Box<dyn FnMut() -> (isize) + '_> {
|
||||
| ^^
|
||||
help: alternatively, set an explicit `'static` lifetime in this parameter
|
||||
help: alternatively, add an explicit `'static` bound to this reference
|
||||
|
|
||||
LL | fn static_proc(x: &'static isize) -> Box<dyn FnMut() -> (isize) + 'static> {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
|
@ -2,7 +2,7 @@ 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 }
|
||||
| ^^^^ ---------- ---------- ...and required to live as long as `'static` by this
|
||||
| ^^^^ ---------- ---------- ...and is required to live as long as `'static` here
|
||||
| | |
|
||||
| | this data with an anonymous lifetime `'_`...
|
||||
| ...is captured here...
|
||||
|
|
|
@ -4,10 +4,10 @@ error[E0758]: cannot infer an appropriate lifetime
|
|||
LL | fn f(self: Pin<&Self>) -> impl Clone { self }
|
||||
| ---------- ---------- ^^^^ ...and is captured here
|
||||
| | |
|
||||
| | ...is required to live as long as `'static` by this...
|
||||
| | ...is required to live as long as `'static` here...
|
||||
| this data with an anonymous lifetime `'_`...
|
||||
|
|
||||
help: to permit non-static references in an `impl Trait` value, you can add an explicit bound for an anonymous lifetime `'_`
|
||||
help: to declare that the `impl Trait` captures data from argument `self`, you can add an explicit `'_` lifetime bound
|
||||
|
|
||||
LL | fn f(self: Pin<&Self>) -> impl Clone + '_ { self }
|
||||
| ^^^^
|
||||
|
|
|
@ -10,7 +10,7 @@ error[E0758]: cannot infer an appropriate lifetime
|
|||
--> $DIR/missing-lifetimes-in-signature.rs:19:5
|
||||
|
|
||||
LL | fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce()
|
||||
| ------ ------------- ...is required to live as long as `'static` by this...
|
||||
| ------ ------------- ...is required to live as long as `'static` here...
|
||||
| |
|
||||
| this data with an anonymous lifetime `'_`...
|
||||
...
|
||||
|
@ -19,7 +19,7 @@ LL | | *dest = g.get();
|
|||
LL | | }
|
||||
| |_____^ ...and is captured here
|
||||
|
|
||||
help: to permit non-static references in an `impl Trait` value, you can add an explicit bound for an anonymous lifetime `'_`
|
||||
help: to declare that the `impl Trait` captures data from argument `dest`, you can add an explicit `'_` lifetime bound
|
||||
|
|
||||
LL | fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
| ^^^^
|
||||
|
|
|
@ -7,7 +7,7 @@ LL | // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to
|
|||
LL | Box::new(items.iter())
|
||||
| ---------------^^^^--- ...is captured and required live as long as `'static` here
|
||||
|
|
||||
help: to permit non-static references in a trait object value, you can add an explicit bound for an anonymous lifetime `'_`
|
||||
help: to declare that the trait object captures data from argument `items`, you can add an explicit `'_` lifetime bound
|
||||
|
|
||||
LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T> + '_> {
|
||||
| ^^^^
|
||||
|
|
Loading…
Reference in New Issue