Rollup merge of #96409 - marmeladema:fix-nll-introduce-named-lifetime-suggestion, r=jackh726
Recover suggestions to introduce named lifetime under NLL Fixes #96157 r? ```@jackh726``` Built on top of #96385 so only the second commit is relevant
This commit is contained in:
commit
cbfbc3be7d
20 changed files with 333 additions and 78 deletions
|
@ -2,7 +2,10 @@
|
||||||
|
|
||||||
use rustc_errors::{Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
|
use rustc_errors::{Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
|
||||||
use rustc_infer::infer::{
|
use rustc_infer::infer::{
|
||||||
error_reporting::nice_region_error::{self, find_param_with_region, NiceRegionError},
|
error_reporting::nice_region_error::{
|
||||||
|
self, find_anon_type, find_param_with_region, suggest_adding_lifetime_params,
|
||||||
|
NiceRegionError,
|
||||||
|
},
|
||||||
error_reporting::unexpected_hidden_region_diagnostic,
|
error_reporting::unexpected_hidden_region_diagnostic,
|
||||||
NllRegionVariableOrigin, RelateParamBound,
|
NllRegionVariableOrigin, RelateParamBound,
|
||||||
};
|
};
|
||||||
|
@ -630,6 +633,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.add_static_impl_trait_suggestion(&mut diag, *fr, fr_name, *outlived_fr);
|
self.add_static_impl_trait_suggestion(&mut diag, *fr, fr_name, *outlived_fr);
|
||||||
|
self.suggest_adding_lifetime_params(&mut diag, *fr, *outlived_fr);
|
||||||
|
|
||||||
diag
|
diag
|
||||||
}
|
}
|
||||||
|
@ -694,4 +698,33 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn suggest_adding_lifetime_params(
|
||||||
|
&self,
|
||||||
|
diag: &mut Diagnostic,
|
||||||
|
sub: RegionVid,
|
||||||
|
sup: RegionVid,
|
||||||
|
) {
|
||||||
|
let (Some(sub), Some(sup)) = (self.to_error_region(sub), self.to_error_region(sup)) else {
|
||||||
|
return
|
||||||
|
};
|
||||||
|
|
||||||
|
let Some((ty_sub, _)) = self
|
||||||
|
.infcx
|
||||||
|
.tcx
|
||||||
|
.is_suitable_region(sub)
|
||||||
|
.and_then(|anon_reg| find_anon_type(self.infcx.tcx, sub, &anon_reg.boundregion)) else {
|
||||||
|
return
|
||||||
|
};
|
||||||
|
|
||||||
|
let Some((ty_sup, _)) = self
|
||||||
|
.infcx
|
||||||
|
.tcx
|
||||||
|
.is_suitable_region(sup)
|
||||||
|
.and_then(|anon_reg| find_anon_type(self.infcx.tcx, sup, &anon_reg.boundregion)) else {
|
||||||
|
return
|
||||||
|
};
|
||||||
|
|
||||||
|
suggest_adding_lifetime_params(self.infcx.tcx, sub, ty_sup, ty_sub, diag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ use crate::infer::error_reporting::nice_region_error::util::AnonymousParamInfo;
|
||||||
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
|
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
|
||||||
use crate::infer::lexical_region_resolve::RegionResolutionError;
|
use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||||
use crate::infer::SubregionOrigin;
|
use crate::infer::SubregionOrigin;
|
||||||
|
use crate::infer::TyCtxt;
|
||||||
|
|
||||||
use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed};
|
use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
|
@ -145,45 +146,53 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.suggest_adding_lifetime_params(sub, ty_sup, ty_sub, &mut err);
|
if suggest_adding_lifetime_params(self.tcx(), sub, ty_sup, ty_sub, &mut err) {
|
||||||
|
err.note("each elided lifetime in input position becomes a distinct lifetime");
|
||||||
|
}
|
||||||
|
|
||||||
let reported = err.emit();
|
let reported = err.emit();
|
||||||
Some(reported)
|
Some(reported)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn suggest_adding_lifetime_params(
|
pub fn suggest_adding_lifetime_params<'tcx>(
|
||||||
&self,
|
tcx: TyCtxt<'tcx>,
|
||||||
sub: Region<'tcx>,
|
sub: Region<'tcx>,
|
||||||
ty_sup: &Ty<'_>,
|
ty_sup: &Ty<'_>,
|
||||||
ty_sub: &Ty<'_>,
|
ty_sub: &Ty<'_>,
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
) {
|
) -> bool {
|
||||||
if let (
|
let (
|
||||||
hir::Ty { kind: hir::TyKind::Rptr(lifetime_sub, _), .. },
|
hir::Ty { kind: hir::TyKind::Rptr(lifetime_sub, _), .. },
|
||||||
hir::Ty { kind: hir::TyKind::Rptr(lifetime_sup, _), .. },
|
hir::Ty { kind: hir::TyKind::Rptr(lifetime_sup, _), .. },
|
||||||
) = (ty_sub, ty_sup)
|
) = (ty_sub, ty_sup) else {
|
||||||
{
|
return false;
|
||||||
if lifetime_sub.name.is_elided() && lifetime_sup.name.is_elided() {
|
};
|
||||||
if let Some(anon_reg) = self.tcx().is_suitable_region(sub) {
|
|
||||||
let hir_id = self.tcx().hir().local_def_id_to_hir_id(anon_reg.def_id);
|
|
||||||
|
|
||||||
let node = self.tcx().hir().get(hir_id);
|
if !lifetime_sub.name.is_elided() || !lifetime_sup.name.is_elided() {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
let Some(anon_reg) = tcx.is_suitable_region(sub) else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
let hir_id = tcx.hir().local_def_id_to_hir_id(anon_reg.def_id);
|
||||||
|
|
||||||
|
let node = tcx.hir().get(hir_id);
|
||||||
let is_impl = matches!(&node, hir::Node::ImplItem(_));
|
let is_impl = matches!(&node, hir::Node::ImplItem(_));
|
||||||
let generics = match node {
|
let generics = match node {
|
||||||
hir::Node::Item(&hir::Item {
|
hir::Node::Item(&hir::Item { kind: hir::ItemKind::Fn(_, ref generics, ..), .. })
|
||||||
kind: hir::ItemKind::Fn(_, ref generics, ..),
|
|
||||||
..
|
|
||||||
})
|
|
||||||
| hir::Node::TraitItem(&hir::TraitItem { ref generics, .. })
|
| hir::Node::TraitItem(&hir::TraitItem { ref generics, .. })
|
||||||
| hir::Node::ImplItem(&hir::ImplItem { ref generics, .. }) => generics,
|
| hir::Node::ImplItem(&hir::ImplItem { ref generics, .. }) => generics,
|
||||||
_ => return,
|
_ => return false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let (suggestion_param_name, introduce_new) = generics
|
let (suggestion_param_name, introduce_new) = generics
|
||||||
.params
|
.params
|
||||||
.iter()
|
.iter()
|
||||||
.find(|p| matches!(p.kind, GenericParamKind::Lifetime { .. }))
|
.find(|p| matches!(p.kind, GenericParamKind::Lifetime { .. }))
|
||||||
.and_then(|p| self.tcx().sess.source_map().span_to_snippet(p.span).ok())
|
.and_then(|p| tcx.sess.source_map().span_to_snippet(p.span).ok())
|
||||||
.map(|name| (name, false))
|
.map(|name| (name, false))
|
||||||
.unwrap_or_else(|| ("'a".to_string(), true));
|
.unwrap_or_else(|| ("'a".to_string(), true));
|
||||||
|
|
||||||
|
@ -203,9 +212,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||||
if introduce_new {
|
if introduce_new {
|
||||||
let new_param_suggestion = match &generics.params {
|
let new_param_suggestion = match &generics.params {
|
||||||
[] => (generics.span, format!("<{}>", suggestion_param_name)),
|
[] => (generics.span, format!("<{}>", suggestion_param_name)),
|
||||||
[first, ..] => {
|
[first, ..] => (first.span.shrink_to_lo(), format!("{}, ", suggestion_param_name)),
|
||||||
(first.span.shrink_to_lo(), format!("{}, ", suggestion_param_name))
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
suggestions.push(new_param_suggestion);
|
suggestions.push(new_param_suggestion);
|
||||||
|
@ -215,14 +222,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||||
if is_impl {
|
if is_impl {
|
||||||
sugg.push_str(" and update trait if needed");
|
sugg.push_str(" and update trait if needed");
|
||||||
}
|
}
|
||||||
err.multipart_suggestion(
|
err.multipart_suggestion(sugg.as_str(), suggestions, Applicability::MaybeIncorrect);
|
||||||
sugg.as_str(),
|
|
||||||
suggestions,
|
true
|
||||||
Applicability::MaybeIncorrect,
|
|
||||||
);
|
|
||||||
err.note("each elided lifetime in input position becomes a distinct lifetime");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ use rustc_middle::ty::{self, Region, TyCtxt};
|
||||||
/// ```
|
/// ```
|
||||||
/// The function returns the nested type corresponding to the anonymous region
|
/// The function returns the nested type corresponding to the anonymous region
|
||||||
/// for e.g., `&u8` and `Vec<&u8>`.
|
/// for e.g., `&u8` and `Vec<&u8>`.
|
||||||
pub(crate) fn find_anon_type<'tcx>(
|
pub fn find_anon_type<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
region: Region<'tcx>,
|
region: Region<'tcx>,
|
||||||
br: &ty::BoundRegionKind,
|
br: &ty::BoundRegionKind,
|
||||||
|
|
|
@ -14,6 +14,8 @@ mod static_impl_trait;
|
||||||
mod trait_impl_difference;
|
mod trait_impl_difference;
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
|
pub use different_lifetimes::suggest_adding_lifetime_params;
|
||||||
|
pub use find_anon_type::find_anon_type;
|
||||||
pub use static_impl_trait::suggest_new_region_bound;
|
pub use static_impl_trait::suggest_new_region_bound;
|
||||||
pub use util::find_param_with_region;
|
pub use util::find_param_with_region;
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,11 @@ LL | pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); }
|
||||||
| | |
|
| | |
|
||||||
| | let's call the lifetime of this reference `'1`
|
| | let's call the lifetime of this reference `'1`
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter
|
||||||
|
|
|
||||||
|
LL | pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); }
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/issue-90170-elision-mismatch.rs:5:44
|
--> $DIR/issue-90170-elision-mismatch.rs:5:44
|
||||||
|
@ -15,6 +20,11 @@ LL | pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); }
|
||||||
| | |
|
| | |
|
||||||
| | let's call the lifetime of this reference `'1`
|
| | let's call the lifetime of this reference `'1`
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter
|
||||||
|
|
|
||||||
|
LL | pub fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); }
|
||||||
|
| ++++ ~~ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/issue-90170-elision-mismatch.rs:7:63
|
--> $DIR/issue-90170-elision-mismatch.rs:7:63
|
||||||
|
@ -24,6 +34,11 @@ LL | pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); }
|
||||||
| | |
|
| | |
|
||||||
| | let's call the lifetime of this reference `'1`
|
| | let's call the lifetime of this reference `'1`
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter
|
||||||
|
|
|
||||||
|
LL | pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); }
|
||||||
|
| ++ ++
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,11 @@ LL | fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | *v = x;
|
LL | *v = x;
|
||||||
| ^^^^^^ assignment requires that `'1` must outlive `'2`
|
| ^^^^^^ assignment requires that `'1` must outlive `'2`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter
|
||||||
|
|
|
||||||
|
LL | fn foo<'a>(&mut (ref mut v, w): &mut (&'a u8, &u8), x: &'a u8) {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,11 @@ LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | z.push((x,y));
|
LL | z.push((x,y));
|
||||||
| ^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
|
| ^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter
|
||||||
|
|
|
||||||
|
LL | fn foo<'a>(z: &mut Vec<(&'a u8,&u8)>, (x, y): (&'a u8, &u8)) {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ex3-both-anon-regions-3.rs:2:5
|
--> $DIR/ex3-both-anon-regions-3.rs:2:5
|
||||||
|
@ -17,6 +22,11 @@ LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) {
|
||||||
| let's call the lifetime of this reference `'4`
|
| let's call the lifetime of this reference `'4`
|
||||||
LL | z.push((x,y));
|
LL | z.push((x,y));
|
||||||
| ^^^^^^^^^^^^^ argument requires that `'3` must outlive `'4`
|
| ^^^^^^^^^^^^^ argument requires that `'3` must outlive `'4`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter
|
||||||
|
|
|
||||||
|
LL | fn foo<'a>(z: &mut Vec<(&u8,&'a u8)>, (x, y): (&u8, &'a u8)) {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,11 @@ LL | fn foo<'a>(&self, x: &i32) -> &i32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | x
|
LL | x
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn foo<'a>(&'a self, x: &'a i32) -> &i32 {
|
||||||
|
| ++ ++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,11 @@ LL | fn foo<'a>(&self, x: &Foo) -> &Foo {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | if true { x } else { self }
|
LL | if true { x } else { self }
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn foo<'a>(&'a self, x: &'a Foo) -> &Foo {
|
||||||
|
| ++ ++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,11 @@ LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | y.push(z);
|
LL | y.push(z);
|
||||||
| ^^^^^^^^^ argument requires that `'1` must outlive `'2`
|
| ^^^^^^^^^ argument requires that `'1` must outlive `'2`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter
|
||||||
|
|
|
||||||
|
LL | fn foo<'a>(x:fn(&u8, &u8), y: Vec<&'a u8>, z: &'a u8) {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
|
error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
|
||||||
--> $DIR/ex3-both-anon-regions-using-fn-items.rs:2:3
|
--> $DIR/ex3-both-anon-regions-using-fn-items.rs:2:3
|
||||||
|
|
|
@ -7,6 +7,11 @@ LL | fn foo(x: &mut Vec<&u8>, y: &u8) {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | x.push(y);
|
LL | x.push(y);
|
||||||
| ^^^^^^^^^ argument requires that `'1` must outlive `'2`
|
| ^^^^^^^^^ argument requires that `'1` must outlive `'2`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,11 @@ LL | fn foo(x:Box<dyn Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | y.push(z);
|
LL | y.push(z);
|
||||||
| ^^^^^^^^^ argument requires that `'1` must outlive `'2`
|
| ^^^^^^^^^ argument requires that `'1` must outlive `'2`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter
|
||||||
|
|
|
||||||
|
LL | fn foo<'a>(x:Box<dyn Fn(&'a u8, &'a u8)> , y: Vec<&u8>, z: &u8) {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
|
error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
|
||||||
--> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:3
|
--> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:3
|
||||||
|
|
|
@ -7,6 +7,11 @@ LL | fn foo(x: &mut Vec<&u8>, y: &u8) {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | x.push(y);
|
LL | x.push(y);
|
||||||
| ^^^^^^^^^ argument requires that `'1` must outlive `'2`
|
| ^^^^^^^^^ argument requires that `'1` must outlive `'2`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter
|
||||||
|
|
|
||||||
|
LL | fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,11 @@ LL | fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f }
|
||||||
| | |
|
| | |
|
||||||
| | let's call the lifetime of this reference `'1`
|
| | let's call the lifetime of this reference `'1`
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn a<'a>(self: Pin<&'a Foo>, f: &'a Foo) -> &Foo { f }
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:14:69
|
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:14:69
|
||||||
|
@ -15,6 +20,11 @@ LL | fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self,
|
||||||
| | |
|
| | |
|
||||||
| | let's call the lifetime of this reference `'1`
|
| | let's call the lifetime of this reference `'1`
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn c<'a>(self: Pin<&'a Self>, f: &'a Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) }
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:21:58
|
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:21:58
|
||||||
|
|
|
@ -7,6 +7,11 @@ LL | fn ref_self(&self, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn ref_self<'a>(&'a self, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/lt-ref-self.rs:23:9
|
--> $DIR/lt-ref-self.rs:23:9
|
||||||
|
@ -17,6 +22,11 @@ LL | fn ref_Self(self: &Self, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/lt-ref-self.rs:29:9
|
--> $DIR/lt-ref-self.rs:29:9
|
||||||
|
@ -27,6 +37,11 @@ LL | fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/lt-ref-self.rs:35:9
|
--> $DIR/lt-ref-self.rs:35:9
|
||||||
|
@ -37,6 +52,11 @@ LL | fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/lt-ref-self.rs:41:9
|
--> $DIR/lt-ref-self.rs:41:9
|
||||||
|
@ -47,6 +67,11 @@ LL | fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn box_box_ref_Self<'a>(self: Box<Box<&'a Self>>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/lt-ref-self.rs:47:9
|
--> $DIR/lt-ref-self.rs:47:9
|
||||||
|
@ -57,6 +82,11 @@ LL | fn box_pin_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn box_pin_Self<'a>(self: Box<Pin<&'a Self>>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
error: aborting due to 6 previous errors
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,11 @@ LL | fn ref_self(&mut self, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn ref_self<'a>(&'a mut self, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-mut-self.rs:23:9
|
--> $DIR/ref-mut-self.rs:23:9
|
||||||
|
@ -17,6 +22,11 @@ LL | fn ref_Self(self: &mut Self, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn ref_Self<'a>(self: &'a mut Self, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-mut-self.rs:29:9
|
--> $DIR/ref-mut-self.rs:29:9
|
||||||
|
@ -27,6 +37,11 @@ LL | fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn box_ref_Self<'a>(self: Box<&'a mut Self>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-mut-self.rs:35:9
|
--> $DIR/ref-mut-self.rs:35:9
|
||||||
|
@ -37,6 +52,11 @@ LL | fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn pin_ref_Self<'a>(self: Pin<&'a mut Self>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-mut-self.rs:41:9
|
--> $DIR/ref-mut-self.rs:41:9
|
||||||
|
@ -47,6 +67,11 @@ LL | fn box_box_ref_Self(self: Box<Box<&mut Self>>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn box_box_ref_Self<'a>(self: Box<Box<&'a mut Self>>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-mut-self.rs:47:9
|
--> $DIR/ref-mut-self.rs:47:9
|
||||||
|
@ -57,6 +82,11 @@ LL | fn box_pin_ref_Self(self: Box<Pin<&mut Self>>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn box_pin_ref_Self<'a>(self: Box<Pin<&'a mut Self>>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
error: aborting due to 6 previous errors
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,11 @@ LL | fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn ref_Struct<'a>(self: &'a mut Struct, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-mut-struct.rs:21:9
|
--> $DIR/ref-mut-struct.rs:21:9
|
||||||
|
@ -17,6 +22,11 @@ LL | fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn box_ref_Struct<'a>(self: Box<&'a mut Struct>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-mut-struct.rs:27:9
|
--> $DIR/ref-mut-struct.rs:27:9
|
||||||
|
@ -27,6 +37,11 @@ LL | fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn pin_ref_Struct<'a>(self: Pin<&'a mut Struct>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-mut-struct.rs:33:9
|
--> $DIR/ref-mut-struct.rs:33:9
|
||||||
|
@ -37,6 +52,11 @@ LL | fn box_box_ref_Struct(self: Box<Box<&mut Struct>>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn box_box_ref_Struct<'a>(self: Box<Box<&'a mut Struct>>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-mut-struct.rs:39:9
|
--> $DIR/ref-mut-struct.rs:39:9
|
||||||
|
@ -47,6 +67,11 @@ LL | fn box_pin_ref_Struct(self: Box<Pin<&mut Struct>>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn box_pin_ref_Struct<'a>(self: Box<Pin<&'a mut Struct>>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,11 @@ LL | fn ref_self(&self, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn ref_self<'a>(&'a self, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-self.rs:33:9
|
--> $DIR/ref-self.rs:33:9
|
||||||
|
@ -17,6 +22,11 @@ LL | fn ref_Self(self: &Self, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-self.rs:39:9
|
--> $DIR/ref-self.rs:39:9
|
||||||
|
@ -27,6 +37,11 @@ LL | fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-self.rs:45:9
|
--> $DIR/ref-self.rs:45:9
|
||||||
|
@ -37,6 +52,11 @@ LL | fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-self.rs:51:9
|
--> $DIR/ref-self.rs:51:9
|
||||||
|
@ -47,6 +67,11 @@ LL | fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn box_box_ref_Self<'a>(self: Box<Box<&'a Self>>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-self.rs:57:9
|
--> $DIR/ref-self.rs:57:9
|
||||||
|
@ -57,6 +82,11 @@ LL | fn box_pin_ref_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn box_pin_ref_Self<'a>(self: Box<Pin<&'a Self>>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-self.rs:63:9
|
--> $DIR/ref-self.rs:63:9
|
||||||
|
@ -67,6 +97,11 @@ LL | fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn wrap_ref_Self_Self<'a>(self: Wrap<&'a Self, Self>, f: &'a u8) -> &u8 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: aborting due to 7 previous errors
|
error: aborting due to 7 previous errors
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,11 @@ LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn ref_Struct<'a>(self: &'a Struct, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-struct.rs:21:9
|
--> $DIR/ref-struct.rs:21:9
|
||||||
|
@ -17,6 +22,11 @@ LL | fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn box_ref_Struct<'a>(self: Box<&'a Struct>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-struct.rs:27:9
|
--> $DIR/ref-struct.rs:27:9
|
||||||
|
@ -27,6 +37,11 @@ LL | fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn pin_ref_Struct<'a>(self: Pin<&'a Struct>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-struct.rs:33:9
|
--> $DIR/ref-struct.rs:33:9
|
||||||
|
@ -37,6 +52,11 @@ LL | fn box_box_ref_Struct(self: Box<Box<&Struct>>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn box_box_ref_Struct<'a>(self: Box<Box<&'a Struct>>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ref-struct.rs:39:9
|
--> $DIR/ref-struct.rs:39:9
|
||||||
|
@ -47,6 +67,11 @@ LL | fn box_pin_Struct(self: Box<Pin<&Struct>>, f: &u32) -> &u32 {
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
LL | f
|
LL | f
|
||||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter and update trait if needed
|
||||||
|
|
|
||||||
|
LL | fn box_pin_Struct<'a>(self: Box<Pin<&'a Struct>>, f: &'a u32) -> &u32 {
|
||||||
|
| ++++ ++ ++
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,11 @@ LL | fn foo(x: &mut Vec<&'_ u8>, y: &'_ u8) { x.push(y); }
|
||||||
| | |
|
| | |
|
||||||
| | let's call the lifetime of this reference `'1`
|
| | let's call the lifetime of this reference `'1`
|
||||||
| let's call the lifetime of this reference `'2`
|
| let's call the lifetime of this reference `'2`
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter
|
||||||
|
|
|
||||||
|
LL | fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); }
|
||||||
|
| ++++ ~~ ~~
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue