Tweak wording and add error code
This commit is contained in:
parent
bc15790609
commit
539e9783df
@ -2,7 +2,7 @@
|
||||
|
||||
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
|
||||
use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||
use rustc_errors::{Applicability, ErrorReported};
|
||||
use rustc_errors::{struct_span_err, Applicability, ErrorReported};
|
||||
use rustc_hir::{GenericBound, ItemKind, Lifetime, LifetimeName, TyKind};
|
||||
use rustc_middle::ty::RegionKind;
|
||||
|
||||
@ -35,10 +35,14 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
let (lifetime_name, lifetime) = if sup_r.has_name() {
|
||||
(sup_r.to_string(), format!("lifetime `{}`", sup_r))
|
||||
} else {
|
||||
("'_".to_owned(), "the anonymous lifetime `'_`".to_string())
|
||||
("'_".to_owned(), "an anonymous lifetime `'_`".to_string())
|
||||
};
|
||||
let mut err =
|
||||
self.tcx().sess.struct_span_err(sp, "cannot infer an appropriate lifetime");
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx().sess,
|
||||
sp,
|
||||
E0758,
|
||||
"cannot infer an appropriate lifetime"
|
||||
);
|
||||
err.span_label(
|
||||
param_info.param_ty_span,
|
||||
&format!("this data with {}...", lifetime),
|
||||
@ -61,10 +65,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
// |
|
||||
// LL | fn foo(x: &i32) -> Box<dyn Debug> { Box::new(x) }
|
||||
// | ---- ---------^-
|
||||
// | | | |
|
||||
// | | | ...and is captured here
|
||||
// | | ...is required to be `'static` by this...
|
||||
// | this data with the anonymous lifetime `'_`...
|
||||
//
|
||||
// and instead show:
|
||||
//
|
||||
@ -72,25 +72,28 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
// --> $DIR/must_outlive_least_region_or_bound.rs:18:50
|
||||
// |
|
||||
// LL | fn foo(x: &i32) -> Box<dyn Debug> { Box::new(x) }
|
||||
// | ---- ^ ...is captured here with a `'static` requirement
|
||||
// | |
|
||||
// | this data with the anonymous lifetime `'_`...
|
||||
// |
|
||||
// | ---- ^
|
||||
err.span_label(
|
||||
sup_origin.span(),
|
||||
"...is captured here with a `'static` requirement",
|
||||
"...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 be `'static` by this");
|
||||
err.span_label(
|
||||
return_sp,
|
||||
"...and required to live as long as `'static` by this",
|
||||
);
|
||||
} else {
|
||||
err.span_label(return_sp, "...is required to be `'static` by this...");
|
||||
err.span_label(
|
||||
return_sp,
|
||||
"...is required to live as long as `'static` by this...",
|
||||
);
|
||||
err.span_label(sup_origin.span(), "...and is captured here");
|
||||
}
|
||||
} else {
|
||||
err.span_label(
|
||||
return_sp,
|
||||
"...is captured and required to be `'static` here",
|
||||
"...is captured and required live as long as `'static` here",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
error: cannot infer an appropriate lifetime
|
||||
error[E0758]: cannot infer an appropriate lifetime
|
||||
--> $DIR/issue-62097.rs:12:31
|
||||
|
|
||||
LL | pub async fn run_dummy_fn(&self) {
|
||||
| ^^^^^
|
||||
| |
|
||||
| this data with the anonymous lifetime `'_`...
|
||||
| this data with an anonymous lifetime `'_`...
|
||||
| ...is captured here...
|
||||
LL | foo(|| self.bar()).await;
|
||||
| --- ...and required to be `'static` by this
|
||||
| --- ...and required to live as long as `'static` by this
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -1,24 +1,24 @@
|
||||
error: cannot infer an appropriate lifetime
|
||||
error[E0758]: cannot infer an appropriate lifetime
|
||||
--> $DIR/must_outlive_least_region_or_bound.rs:3:35
|
||||
|
|
||||
LL | fn elided(x: &i32) -> impl Copy { x }
|
||||
| ---- --------- ^ ...and is captured here
|
||||
| | |
|
||||
| | ...is required to be `'static` by this...
|
||||
| this data with the anonymous lifetime `'_`...
|
||||
| | ...is required to live as long as `'static` by this...
|
||||
| this data with an anonymous lifetime `'_`...
|
||||
|
|
||||
help: to permit non-static references in an `impl Trait` value, you can add an explicit bound for the anonymous lifetime `'_`
|
||||
help: to permit non-static references in an `impl Trait` value, you can add an explicit bound for an anonymous lifetime `'_`
|
||||
|
|
||||
LL | fn elided(x: &i32) -> impl Copy + '_ { x }
|
||||
| ^^^^
|
||||
|
||||
error: cannot infer an appropriate lifetime
|
||||
error[E0758]: cannot infer an appropriate lifetime
|
||||
--> $DIR/must_outlive_least_region_or_bound.rs:6:44
|
||||
|
|
||||
LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
|
||||
| ------- --------- ^ ...and is captured here
|
||||
| | |
|
||||
| | ...is required to be `'static` by this...
|
||||
| | ...is required to live as long as `'static` by this...
|
||||
| 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`
|
||||
@ -26,16 +26,16 @@ help: to permit non-static references in an `impl Trait` value, you can add an e
|
||||
LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x }
|
||||
| ^^^^
|
||||
|
||||
error: cannot infer an appropriate lifetime
|
||||
error[E0758]: cannot infer an appropriate lifetime
|
||||
--> $DIR/must_outlive_least_region_or_bound.rs:9:46
|
||||
|
|
||||
LL | fn elided2(x: &i32) -> impl Copy + 'static { x }
|
||||
| ---- ------------------- ^ ...and is captured here
|
||||
| | |
|
||||
| | ...is required to be `'static` by this...
|
||||
| this data with the anonymous lifetime `'_`...
|
||||
| | ...is required to live as long as `'static` by this...
|
||||
| this data with an anonymous lifetime `'_`...
|
||||
|
|
||||
help: consider changing the `impl Trait`'s explicit `'static` bound to the anonymous lifetime `'_`
|
||||
help: consider changing the `impl Trait`'s explicit `'static` bound to an anonymous lifetime `'_`
|
||||
|
|
||||
LL | fn elided2(x: &i32) -> impl Copy + '_ { x }
|
||||
| ^^
|
||||
@ -44,13 +44,13 @@ help: alternatively, set an explicit `'static` lifetime to this parameter
|
||||
LL | fn elided2(x: &'static i32) -> impl Copy + 'static { x }
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: cannot infer an appropriate lifetime
|
||||
error[E0758]: cannot infer an appropriate lifetime
|
||||
--> $DIR/must_outlive_least_region_or_bound.rs:12:55
|
||||
|
|
||||
LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x }
|
||||
| ------- ------------------- ^ ...and is captured here
|
||||
| | |
|
||||
| | ...is required to be `'static` by this...
|
||||
| | ...is required to live as long as `'static` by this...
|
||||
| this data with lifetime `'a`...
|
||||
|
|
||||
help: consider changing the `impl Trait`'s explicit `'static` bound to lifetime `'a`
|
||||
@ -70,13 +70,13 @@ LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x }
|
||||
| |
|
||||
| help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
|
||||
|
||||
error: cannot infer an appropriate lifetime
|
||||
error[E0758]: cannot infer an appropriate lifetime
|
||||
--> $DIR/must_outlive_least_region_or_bound.rs:33:69
|
||||
|
|
||||
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
|
||||
| ------- -------------------------------- ^ ...and is captured here
|
||||
| | |
|
||||
| | ...is required to be `'static` by this...
|
||||
| | ...is required to live as long as `'static` by this...
|
||||
| this data with lifetime `'a`...
|
||||
|
|
||||
help: consider changing the `impl Trait`'s explicit `'static` bound to lifetime `'a`
|
||||
@ -105,24 +105,24 @@ LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static {
|
||||
| |
|
||||
| help: consider adding an explicit lifetime bound...: `T: 'static +`
|
||||
|
||||
error: cannot infer an appropriate lifetime
|
||||
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 with a `'static` requirement
|
||||
| ---- ^ ...is captured here requiring it to live as long as `'static`
|
||||
| |
|
||||
| this data with the anonymous lifetime `'_`...
|
||||
| this data with an anonymous lifetime `'_`...
|
||||
|
|
||||
help: to permit non-static references in a trait object value, you can add an explicit bound for the anonymous lifetime `'_`
|
||||
help: to permit non-static references in a trait object value, you can add an explicit bound for an anonymous lifetime `'_`
|
||||
|
|
||||
LL | fn elided3(x: &i32) -> Box<dyn Debug + '_> { Box::new(x) }
|
||||
| ^^^^
|
||||
|
||||
error: cannot infer an appropriate lifetime
|
||||
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 with a `'static` requirement
|
||||
| ------- ^ ...is captured here requiring it to live as long as `'static`
|
||||
| |
|
||||
| this data with lifetime `'a`...
|
||||
|
|
||||
@ -131,15 +131,15 @@ help: to permit non-static references in a trait object value, you can add an ex
|
||||
LL | fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug + 'a> { Box::new(x) }
|
||||
| ^^^^
|
||||
|
||||
error: cannot infer an appropriate lifetime
|
||||
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 with a `'static` requirement
|
||||
| ---- ^ ...is captured here requiring it to live as long as `'static`
|
||||
| |
|
||||
| this data with the anonymous lifetime `'_`...
|
||||
| this data with an anonymous lifetime `'_`...
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to the anonymous lifetime `'_`
|
||||
help: consider changing the trait object's explicit `'static` bound to an anonymous lifetime `'_`
|
||||
|
|
||||
LL | fn elided4(x: &i32) -> Box<dyn Debug + '_> { Box::new(x) }
|
||||
| ^^
|
||||
@ -148,11 +148,11 @@ help: alternatively, set an explicit `'static` lifetime in this parameter
|
||||
LL | fn elided4(x: &'static i32) -> Box<dyn Debug + 'static> { Box::new(x) }
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: cannot infer an appropriate lifetime
|
||||
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 with a `'static` requirement
|
||||
| ------- 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`
|
||||
|
|
||||
|
@ -1,25 +1,25 @@
|
||||
error: cannot infer an appropriate lifetime
|
||||
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 be `'static` by this...
|
||||
| ----- ----------------------- ...is required to live as long as `'static` by this...
|
||||
| |
|
||||
| this data with the anonymous lifetime `'_`...
|
||||
| this data with an anonymous lifetime `'_`...
|
||||
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 the anonymous lifetime `'_`
|
||||
help: to permit non-static references in an `impl Trait` value, you can add an explicit bound for an anonymous lifetime `'_`
|
||||
|
|
||||
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ {
|
||||
| ^^^^
|
||||
|
||||
error: cannot infer an appropriate lifetime
|
||||
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 be `'static` by this...
|
||||
| -------- ----------------------- ...is required to live as long as `'static` by this...
|
||||
| |
|
||||
| this data with lifetime `'a`...
|
||||
LL | self.x.iter().map(|a| a.0)
|
||||
|
@ -1,12 +1,12 @@
|
||||
error: cannot infer an appropriate lifetime
|
||||
error[E0758]: cannot infer an appropriate lifetime
|
||||
--> $DIR/issue-16922.rs:4:14
|
||||
|
|
||||
LL | fn foo<T: Any>(value: &T) -> Box<dyn Any> {
|
||||
| -- this data with the anonymous lifetime `'_`...
|
||||
| -- this data with an anonymous lifetime `'_`...
|
||||
LL | Box::new(value) as Box<dyn Any>
|
||||
| ^^^^^ ...is captured here with a `'static` requirement
|
||||
| ^^^^^ ...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 the anonymous lifetime `'_`
|
||||
help: to permit non-static references in a trait object value, you can add an explicit bound for an anonymous lifetime `'_`
|
||||
|
|
||||
LL | fn foo<T: Any>(value: &T) -> Box<dyn Any + '_> {
|
||||
| ^^^^
|
||||
|
@ -1,13 +1,13 @@
|
||||
error: cannot infer an appropriate lifetime
|
||||
error[E0758]: cannot infer an appropriate lifetime
|
||||
--> $DIR/object-lifetime-default-from-box-error.rs:18:5
|
||||
|
|
||||
LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> {
|
||||
| --------------- this data with the anonymous lifetime `'_`...
|
||||
| --------------- this data with an anonymous lifetime `'_`...
|
||||
...
|
||||
LL | ss.r
|
||||
| ^^^^ ...is captured and required to be `'static` here
|
||||
| ^^^^ ...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 the anonymous lifetime `'_`
|
||||
help: to permit non-static references in a trait object value, you can add an explicit bound for an anonymous lifetime `'_`
|
||||
|
|
||||
LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait + '_> {
|
||||
| ^^^^
|
||||
|
@ -1,12 +1,12 @@
|
||||
error: cannot infer an appropriate lifetime
|
||||
error[E0758]: cannot infer an appropriate lifetime
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:8:46
|
||||
|
|
||||
LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> {
|
||||
| ----- this data with the anonymous lifetime `'_`...
|
||||
| ----- this data with an anonymous lifetime `'_`...
|
||||
LL | let x: Box<dyn Foo + 'static> = Box::new(v);
|
||||
| ^ ...is captured here with a `'static` requirement
|
||||
| ^ ...is captured here requiring it to live as long as `'static`
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to the anonymous lifetime `'_`
|
||||
help: consider changing the trait object's explicit `'static` bound to an anonymous lifetime `'_`
|
||||
|
|
||||
LL | fn a(v: &[u8]) -> Box<dyn Foo + '_> {
|
||||
| ^^
|
||||
@ -15,15 +15,15 @@ help: alternatively, set an explicit `'static` lifetime in this parameter
|
||||
LL | fn a(v: &'static [u8]) -> Box<dyn Foo + 'static> {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: cannot infer an appropriate lifetime
|
||||
error[E0758]: cannot infer an appropriate lifetime
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:13:14
|
||||
|
|
||||
LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
|
||||
| ----- this data with the anonymous lifetime `'_`...
|
||||
| ----- this data with an anonymous lifetime `'_`...
|
||||
LL | Box::new(v)
|
||||
| ^ ...is captured here with a `'static` requirement
|
||||
| ^ ...is captured here requiring it to live as long as `'static`
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to the anonymous lifetime `'_`
|
||||
help: consider changing the trait object's explicit `'static` bound to an anonymous lifetime `'_`
|
||||
|
|
||||
LL | fn b(v: &[u8]) -> Box<dyn Foo + '_> {
|
||||
| ^^
|
||||
@ -32,16 +32,16 @@ help: alternatively, set an explicit `'static` lifetime in this parameter
|
||||
LL | fn b(v: &'static [u8]) -> Box<dyn Foo + 'static> {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: cannot infer an appropriate lifetime
|
||||
error[E0758]: cannot infer an appropriate lifetime
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:19:14
|
||||
|
|
||||
LL | fn c(v: &[u8]) -> Box<dyn Foo> {
|
||||
| ----- this data with the anonymous lifetime `'_`...
|
||||
| ----- this data with an anonymous lifetime `'_`...
|
||||
...
|
||||
LL | Box::new(v)
|
||||
| ^ ...is captured here with a `'static` requirement
|
||||
| ^ ...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 the anonymous lifetime `'_`
|
||||
help: to permit non-static references in a trait object value, you can add an explicit bound for an anonymous lifetime `'_`
|
||||
|
|
||||
LL | fn c(v: &[u8]) -> Box<dyn Foo + '_> {
|
||||
| ^^^^
|
||||
|
@ -1,10 +1,10 @@
|
||||
error: cannot infer an appropriate lifetime
|
||||
error[E0758]: cannot infer an appropriate lifetime
|
||||
--> $DIR/regions-close-object-into-object-2.rs:10:11
|
||||
|
|
||||
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 with a `'static` requirement
|
||||
| ^^^ ...is captured here requiring it to live as long as `'static`
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to lifetime `'a`
|
||||
|
|
||||
|
@ -1,10 +1,10 @@
|
||||
error: cannot infer an appropriate lifetime
|
||||
error[E0758]: cannot infer an appropriate lifetime
|
||||
--> $DIR/regions-close-object-into-object-4.rs:10:11
|
||||
|
|
||||
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 with a `'static` requirement
|
||||
| ^^^ ...is captured here requiring it to live as long as `'static`
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to lifetime `'a`
|
||||
|
|
||||
|
@ -1,13 +1,13 @@
|
||||
error: cannot infer an appropriate lifetime
|
||||
error[E0758]: cannot infer an appropriate lifetime
|
||||
--> $DIR/regions-proc-bound-capture.rs:9:14
|
||||
|
|
||||
LL | fn static_proc(x: &isize) -> Box<dyn FnMut() -> (isize) + 'static> {
|
||||
| ------ this data with the anonymous lifetime `'_`...
|
||||
| ------ 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 with a `'static` requirement
|
||||
| ^^^^^^^^^^^^^^ ...is captured here requiring it to live as long as `'static`
|
||||
|
|
||||
help: consider changing the trait object's explicit `'static` bound to the anonymous lifetime `'_`
|
||||
help: consider changing the trait object's explicit `'static` bound to an anonymous lifetime `'_`
|
||||
|
|
||||
LL | fn static_proc(x: &isize) -> Box<dyn FnMut() -> (isize) + '_> {
|
||||
| ^^
|
||||
|
@ -1,10 +1,10 @@
|
||||
error: cannot infer an appropriate lifetime
|
||||
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 be `'static` by this
|
||||
| ^^^^ ---------- ---------- ...and required to live as long as `'static` by this
|
||||
| | |
|
||||
| | this data with the anonymous lifetime `'_`...
|
||||
| | this data with an anonymous lifetime `'_`...
|
||||
| ...is captured here...
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -1,13 +1,13 @@
|
||||
error: cannot infer an appropriate lifetime
|
||||
error[E0758]: cannot infer an appropriate lifetime
|
||||
--> $DIR/arbitrary_self_types_pin_lifetime_impl_trait.rs:6:44
|
||||
|
|
||||
LL | fn f(self: Pin<&Self>) -> impl Clone { self }
|
||||
| ---------- ---------- ^^^^ ...and is captured here
|
||||
| | |
|
||||
| | ...is required to be `'static` by this...
|
||||
| this data with the anonymous lifetime `'_`...
|
||||
| | ...is required to live as long as `'static` by this...
|
||||
| this data with an anonymous lifetime `'_`...
|
||||
|
|
||||
help: to permit non-static references in an `impl Trait` value, you can add an explicit bound for the anonymous lifetime `'_`
|
||||
help: to permit non-static references in an `impl Trait` value, you can add an explicit bound for an anonymous lifetime `'_`
|
||||
|
|
||||
LL | fn f(self: Pin<&Self>) -> impl Clone + '_ { self }
|
||||
| ^^^^
|
||||
|
@ -6,20 +6,20 @@ LL | fn baz<G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
| |
|
||||
| help: consider introducing lifetime `'a` here: `'a,`
|
||||
|
||||
error: cannot infer an appropriate lifetime
|
||||
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 be `'static` by this...
|
||||
| ------ ------------- ...is required to live as long as `'static` by this...
|
||||
| |
|
||||
| this data with the anonymous lifetime `'_`...
|
||||
| this data with an anonymous lifetime `'_`...
|
||||
...
|
||||
LL | / move || {
|
||||
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 the anonymous lifetime `'_`
|
||||
help: to permit non-static references in an `impl Trait` value, you can add an explicit bound for an anonymous lifetime `'_`
|
||||
|
|
||||
LL | fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
| ^^^^
|
||||
|
@ -1,13 +1,13 @@
|
||||
error: cannot infer an appropriate lifetime
|
||||
error[E0758]: cannot infer an appropriate lifetime
|
||||
--> $DIR/dyn-trait-underscore.rs:8:20
|
||||
|
|
||||
LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
|
||||
| ---- this data with the anonymous lifetime `'_`...
|
||||
| ---- this data with an anonymous lifetime `'_`...
|
||||
LL | // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`
|
||||
LL | Box::new(items.iter())
|
||||
| ---------------^^^^--- ...is captured and required to be `'static` here
|
||||
| ---------------^^^^--- ...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 the anonymous lifetime `'_`
|
||||
help: to permit non-static references in a trait object value, you can add an explicit bound for an anonymous lifetime `'_`
|
||||
|
|
||||
LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T> + '_> {
|
||||
| ^^^^
|
||||
|
Loading…
Reference in New Issue
Block a user