From da175c743c3dbf7fc371534acbbd6a1bf0b17d50 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Thu, 12 May 2022 21:25:38 +0200 Subject: [PATCH] Make lifetime errors more precise in the presence of `Fresh` lifetimes. --- compiler/rustc_hir/src/hir.rs | 11 +++++ .../src/infer/error_reporting/mod.rs | 16 +++++-- .../nice_region_error/different_lifetimes.rs | 48 +++++++++++-------- .../nice_region_error/named_anon_conflict.rs | 3 +- .../ui/async-await/issue-76547.base.stderr | 12 +++++ .../ui/async-await/issue-76547.nll.stderr | 10 ++++ .../issues/issue-63388-1.base.stderr | 10 ++-- .../issues/issue-63388-1.nll.stderr | 9 ++-- .../ui/async-await/issues/issue-63388-1.rs | 4 +- src/test/ui/error-codes/E0308-2.stderr | 2 +- src/test/ui/issues/issue-17905-2.stderr | 4 +- src/test/ui/issues/issue-65230.stderr | 2 +- src/test/ui/nll/issue-52742.base.stderr | 2 +- src/test/ui/nll/issue-55394.base.stderr | 2 +- ...types_pin_lifetime_impl_trait-async.stderr | 2 +- ...es_pin_lifetime_mismatch-async.base.stderr | 12 +++++ ...pes_pin_lifetime_mismatch-async.nll.stderr | 10 ++++ .../elision/lt-ref-self-async.base.stderr | 36 ++++++++++++++ .../self/elision/lt-ref-self-async.nll.stderr | 30 ++++++++++++ .../elision/ref-mut-self-async.base.stderr | 36 ++++++++++++++ .../elision/ref-mut-self-async.nll.stderr | 30 ++++++++++++ .../elision/ref-mut-struct-async.base.stderr | 30 ++++++++++++ .../elision/ref-mut-struct-async.nll.stderr | 25 ++++++++++ .../self/elision/ref-self-async.base.stderr | 42 ++++++++++++++++ .../ui/self/elision/ref-self-async.nll.stderr | 35 ++++++++++++++ .../self/elision/ref-struct-async.base.stderr | 30 ++++++++++++ .../self/elision/ref-struct-async.nll.stderr | 25 ++++++++++ 27 files changed, 433 insertions(+), 45 deletions(-) diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index bda7affe529..dbe6fe6ea84 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -131,6 +131,17 @@ pub fn ident(&self) -> Ident { } } + pub fn is_anonymous(&self) -> bool { + match *self { + LifetimeName::ImplicitObjectLifetimeDefault + | LifetimeName::Implicit + | LifetimeName::Underscore + | LifetimeName::Param(ParamName::Fresh(_)) + | LifetimeName::Error => true, + LifetimeName::Static | LifetimeName::Param(_) => false, + } + } + pub fn is_elided(&self) -> bool { match self { LifetimeName::ImplicitObjectLifetimeDefault diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 11c893a7cb6..a2bd11f8b8e 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -72,7 +72,7 @@ subst::{GenericArgKind, Subst, SubstsRef}, Binder, EarlyBinder, List, Region, Ty, TyCtxt, TypeFoldable, }; -use rustc_span::{sym, BytePos, DesugaringKind, Pos, Span}; +use rustc_span::{sym, symbol::kw, BytePos, DesugaringKind, Pos, Span}; use rustc_target::spec::abi; use std::ops::ControlFlow; use std::{cmp, fmt, iter}; @@ -161,7 +161,12 @@ fn msg_span_from_early_bound_and_free_regions<'tcx>( { sp = param.span; } - (format!("the lifetime `{}` as defined here", br.name), sp) + let text = if br.name == kw::UnderscoreLifetime { + format!("the anonymous lifetime as defined here") + } else { + format!("the lifetime `{}` as defined here", br.name) + }; + (text, sp) } ty::ReFree(ty::FreeRegion { bound_region: ty::BoundRegionKind::BrNamed(_, name), .. @@ -172,7 +177,12 @@ fn msg_span_from_early_bound_and_free_regions<'tcx>( { sp = param.span; } - (format!("the lifetime `{}` as defined here", name), sp) + let text = if name == kw::UnderscoreLifetime { + format!("the anonymous lifetime as defined here") + } else { + format!("the lifetime `{}` as defined here", name) + }; + (text, sp) } ty::ReFree(ref fr) => match fr.bound_region { ty::BrAnon(idx) => { diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs index cb72cb41a7c..b744594ddb7 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs @@ -12,6 +12,7 @@ use rustc_hir as hir; use rustc_hir::{GenericParamKind, Ty}; use rustc_middle::ty::Region; +use rustc_span::symbol::kw; impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { /// Print the error message for lifetime errors when both the concerned regions are anonymous. @@ -169,7 +170,7 @@ pub fn suggest_adding_lifetime_params<'tcx>( return false; }; - if !lifetime_sub.name.is_elided() || !lifetime_sup.name.is_elided() { + if !lifetime_sub.name.is_anonymous() || !lifetime_sup.name.is_anonymous() { return false; }; @@ -188,32 +189,37 @@ pub fn suggest_adding_lifetime_params<'tcx>( _ => return false, }; - let (suggestion_param_name, introduce_new) = generics + let suggestion_param_name = generics .params .iter() - .find(|p| matches!(p.kind, GenericParamKind::Lifetime { .. })) - .and_then(|p| tcx.sess.source_map().span_to_snippet(p.span).ok()) - .map(|name| (name, false)) - .unwrap_or_else(|| ("'a".to_string(), true)); + .filter(|p| matches!(p.kind, GenericParamKind::Lifetime { .. })) + .map(|p| p.name.ident().name) + .find(|i| *i != kw::UnderscoreLifetime); + let introduce_new = suggestion_param_name.is_none(); + let suggestion_param_name = + suggestion_param_name.map(|n| n.to_string()).unwrap_or_else(|| "'a".to_owned()); - let mut suggestions = vec![ - if let hir::LifetimeName::Underscore = lifetime_sub.name { - (lifetime_sub.span, suggestion_param_name.clone()) + debug!(?lifetime_sup.span); + debug!(?lifetime_sub.span); + let make_suggestion = |span: rustc_span::Span| { + if span.is_empty() { + (span, format!("{}, ", suggestion_param_name)) + } else if let Ok("&") = tcx.sess.source_map().span_to_snippet(span).as_deref() { + (span.shrink_to_hi(), format!("{} ", suggestion_param_name)) } else { - (lifetime_sub.span.shrink_to_hi(), suggestion_param_name.clone() + " ") - }, - if let hir::LifetimeName::Underscore = lifetime_sup.name { - (lifetime_sup.span, suggestion_param_name.clone()) - } else { - (lifetime_sup.span.shrink_to_hi(), suggestion_param_name.clone() + " ") - }, - ]; + (span, suggestion_param_name.clone()) + } + }; + let mut suggestions = + vec![make_suggestion(lifetime_sub.span), make_suggestion(lifetime_sup.span)]; if introduce_new { - let new_param_suggestion = match &generics.params { - [] => (generics.span, format!("<{}>", suggestion_param_name)), - [first, ..] => (first.span.shrink_to_lo(), format!("{}, ", suggestion_param_name)), - }; + let new_param_suggestion = + if let Some(first) = generics.params.iter().find(|p| !p.name.ident().span.is_empty()) { + (first.span.shrink_to_lo(), format!("{}, ", suggestion_param_name)) + } else { + (generics.span, format!("<{}>", suggestion_param_name)) + }; suggestions.push(new_param_suggestion); } diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs index 3de5273d8c7..375ad8d3736 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs @@ -4,6 +4,7 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError; use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed}; use rustc_middle::ty; +use rustc_span::symbol::kw; impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { /// When given a `ConcreteFailure` for a function with parameters containing a named region and @@ -67,7 +68,7 @@ pub(super) fn try_report_named_anon_conflict( let is_impl_item = region_info.is_impl_item; match br { - ty::BrAnon(_) => {} + ty::BrNamed(_, kw::UnderscoreLifetime) | ty::BrAnon(_) => {} _ => { /* not an anonymous region */ debug!("try_report_named_anon_conflict: not an anonymous region"); diff --git a/src/test/ui/async-await/issue-76547.base.stderr b/src/test/ui/async-await/issue-76547.base.stderr index 34705d4838e..109883fbeb7 100644 --- a/src/test/ui/async-await/issue-76547.base.stderr +++ b/src/test/ui/async-await/issue-76547.base.stderr @@ -5,6 +5,12 @@ LL | async fn fut(bufs: &mut [&mut [u8]]) { | ---------------- these two types are declared with different lifetimes... LL | ListFut(bufs).await | ^^^^ ...but data from `bufs` flows into `bufs` here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter + | +LL | async fn fut<'a>(bufs: &'a mut [&'a mut [u8]]) { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/issue-76547.rs:39:14 @@ -13,6 +19,12 @@ LL | async fn fut2(bufs: &mut [&mut [u8]]) -> i32 { | ---------------- these two types are declared with different lifetimes... LL | ListFut2(bufs).await | ^^^^ ...but data from `bufs` flows into `bufs` here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter + | +LL | async fn fut2<'a>(bufs: &'a mut [&'a mut [u8]]) -> i32 { + | ++++ ++ ++ error: aborting due to 2 previous errors diff --git a/src/test/ui/async-await/issue-76547.nll.stderr b/src/test/ui/async-await/issue-76547.nll.stderr index bc30da1e389..0a5a52cb79e 100644 --- a/src/test/ui/async-await/issue-76547.nll.stderr +++ b/src/test/ui/async-await/issue-76547.nll.stderr @@ -7,6 +7,11 @@ LL | async fn fut(bufs: &mut [&mut [u8]]) { | let's call the lifetime of this reference `'1` LL | ListFut(bufs).await | ^^^^ this usage requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | async fn fut<'a>(bufs: &'a mut [&'a mut [u8]]) { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/issue-76547.rs:39:14 @@ -17,6 +22,11 @@ LL | async fn fut2(bufs: &mut [&mut [u8]]) -> i32 { | let's call the lifetime of this reference `'1` LL | ListFut2(bufs).await | ^^^^ this usage requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | async fn fut2<'a>(bufs: &'a mut [&'a mut [u8]]) -> i32 { + | ++++ ++ ++ error: aborting due to 2 previous errors diff --git a/src/test/ui/async-await/issues/issue-63388-1.base.stderr b/src/test/ui/async-await/issues/issue-63388-1.base.stderr index 2ff85a27a46..f5409a7ca5d 100644 --- a/src/test/ui/async-await/issues/issue-63388-1.base.stderr +++ b/src/test/ui/async-await/issues/issue-63388-1.base.stderr @@ -1,14 +1,12 @@ -error[E0623]: lifetime mismatch +error[E0621]: explicit lifetime required in the type of `foo` --> $DIR/issue-63388-1.rs:19:9 | LL | &'a self, foo: &dyn Foo - | -------- this parameter and the return type are declared with different lifetimes... -LL | ) -> &dyn Foo - | -------- + | -------- help: add explicit lifetime `'a` to the type of `foo`: `&'a (dyn Foo + 'a)` ... LL | foo - | ^^^ ...but data from `foo` is returned here + | ^^^ lifetime `'a` required error: aborting due to previous error -For more information about this error, try `rustc --explain E0623`. +For more information about this error, try `rustc --explain E0621`. diff --git a/src/test/ui/async-await/issues/issue-63388-1.nll.stderr b/src/test/ui/async-await/issues/issue-63388-1.nll.stderr index eee0cee278b..9263a81bb6a 100644 --- a/src/test/ui/async-await/issues/issue-63388-1.nll.stderr +++ b/src/test/ui/async-await/issues/issue-63388-1.nll.stderr @@ -1,17 +1,16 @@ -error: lifetime may not live long enough +error[E0621]: explicit lifetime required in the type of `foo` --> $DIR/issue-63388-1.rs:17:5 | -LL | async fn do_sth<'a>( - | -- lifetime `'a` defined here LL | &'a self, foo: &dyn Foo - | - let's call the lifetime of this reference `'1` + | -------- help: add explicit lifetime `'a` to the type of `foo`: `&'a (dyn Foo + 'a)` LL | ) -> &dyn Foo LL | / { LL | | LL | | foo LL | | LL | | } - | |_____^ associated function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1` + | |_____^ lifetime `'a` required error: aborting due to previous error +For more information about this error, try `rustc --explain E0621`. diff --git a/src/test/ui/async-await/issues/issue-63388-1.rs b/src/test/ui/async-await/issues/issue-63388-1.rs index c45d2a42177..f00f9295406 100644 --- a/src/test/ui/async-await/issues/issue-63388-1.rs +++ b/src/test/ui/async-await/issues/issue-63388-1.rs @@ -15,9 +15,9 @@ async fn do_sth<'a>( &'a self, foo: &dyn Foo ) -> &dyn Foo { - //[nll]~^ ERROR lifetime may not live long enough + //[nll]~^ ERROR explicit lifetime required in the type of `foo` [E0621] foo - //[base]~^ ERROR lifetime mismatch + //[base]~^ ERROR explicit lifetime required in the type of `foo` [E0621] } } diff --git a/src/test/ui/error-codes/E0308-2.stderr b/src/test/ui/error-codes/E0308-2.stderr index 5c1dcb4d4f9..de54a417253 100644 --- a/src/test/ui/error-codes/E0308-2.stderr +++ b/src/test/ui/error-codes/E0308-2.stderr @@ -6,7 +6,7 @@ LL | impl Eq for &dyn DynEq {} | = note: expected trait `<&dyn DynEq as PartialEq>` found trait `<&(dyn DynEq + 'static) as PartialEq>` -note: the lifetime `'_` as defined here... +note: the anonymous lifetime as defined here... --> $DIR/E0308-2.rs:9:13 | LL | impl Eq for &dyn DynEq {} diff --git a/src/test/ui/issues/issue-17905-2.stderr b/src/test/ui/issues/issue-17905-2.stderr index c68265f71f2..88b5fbec6cf 100644 --- a/src/test/ui/issues/issue-17905-2.stderr +++ b/src/test/ui/issues/issue-17905-2.stderr @@ -11,7 +11,7 @@ note: the anonymous lifetime defined here... | LL | fn say(self: &Pair<&str, isize>) { | ^^^^ -note: ...does not necessarily outlive the lifetime `'_` as defined here +note: ...does not necessarily outlive the anonymous lifetime as defined here --> $DIR/issue-17905-2.rs:5:5 | LL | &str, @@ -25,7 +25,7 @@ LL | fn say(self: &Pair<&str, isize>) { | = note: expected struct `Pair<&str, _>` found struct `Pair<&str, _>` -note: the lifetime `'_` as defined here... +note: the anonymous lifetime as defined here... --> $DIR/issue-17905-2.rs:5:5 | LL | &str, diff --git a/src/test/ui/issues/issue-65230.stderr b/src/test/ui/issues/issue-65230.stderr index bfeb38d6471..fcabcdea74f 100644 --- a/src/test/ui/issues/issue-65230.stderr +++ b/src/test/ui/issues/issue-65230.stderr @@ -6,7 +6,7 @@ LL | impl T1 for &dyn T2 {} | = note: expected trait `<&dyn T2 as T0>` found trait `<&(dyn T2 + 'static) as T0>` -note: the lifetime `'_` as defined here... +note: the anonymous lifetime as defined here... --> $DIR/issue-65230.rs:8:13 | LL | impl T1 for &dyn T2 {} diff --git a/src/test/ui/nll/issue-52742.base.stderr b/src/test/ui/nll/issue-52742.base.stderr index 259f378f70b..7b1fac082e4 100644 --- a/src/test/ui/nll/issue-52742.base.stderr +++ b/src/test/ui/nll/issue-52742.base.stderr @@ -4,7 +4,7 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content... LL | self.y = b.z | ^^^ | -note: ...the reference is valid for the lifetime `'_` as defined here... +note: ...the reference is valid for the anonymous lifetime as defined here... --> $DIR/issue-52742.rs:15:10 | LL | impl Foo<'_, '_> { diff --git a/src/test/ui/nll/issue-55394.base.stderr b/src/test/ui/nll/issue-55394.base.stderr index cc87954732c..2ec6a7af3f2 100644 --- a/src/test/ui/nll/issue-55394.base.stderr +++ b/src/test/ui/nll/issue-55394.base.stderr @@ -14,7 +14,7 @@ note: ...so that reference does not outlive borrowed content | LL | Foo { bar } | ^^^ -note: but, the lifetime must be valid for the lifetime `'_` as defined here... +note: but, the lifetime must be valid for the anonymous lifetime as defined here... --> $DIR/issue-55394.rs:11:10 | LL | impl Foo<'_> { diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr index 570a08cb587..a0a42e3adbf 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn f(self: Pin<&Self>) -> impl Clone { self } | - ^^^^^^^^ | | - | hidden type `Pin<&Foo>` captures the lifetime `'_` as defined here + | hidden type `Pin<&Foo>` captures the anonymous lifetime as defined here | help: to declare that the `impl Trait` captures `'_`, you can add an explicit `'_` lifetime bound | diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.base.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.base.stderr index 7985bf266d8..d2106630dfe 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.base.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.base.stderr @@ -5,6 +5,12 @@ LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } | ---- ---- ^ ...but data from `f` is returned here | | | this parameter and the return type are declared with different lifetimes... + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn a<'a>(self: Pin<&'a Foo>, f: &'a Foo) -> &Foo { f } + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:82 @@ -13,6 +19,12 @@ LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { ( | ---- ----------------- ^ ...but data from `f` is returned here | | | this parameter and the return type are declared with different lifetimes... + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn c<'a>(self: Pin<&'a Self>, f: &'a Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:22:64 diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr index 8a55a7c34d7..3fd58725d02 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr @@ -6,6 +6,11 @@ LL | async 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 `'2` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn a<'a>(self: Pin<&'a Foo>, f: &'a Foo) -> &Foo { f } + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:75 @@ -15,6 +20,11 @@ LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { ( | | | | | let's call the lifetime of this reference `'1` | let's call the lifetime of this reference `'2` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn c<'a>(self: Pin<&'a Self>, f: &'a Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:22:64 diff --git a/src/test/ui/self/elision/lt-ref-self-async.base.stderr b/src/test/ui/self/elision/lt-ref-self-async.base.stderr index b4385490614..0e2bbcc3c04 100644 --- a/src/test/ui/self/elision/lt-ref-self-async.base.stderr +++ b/src/test/ui/self/elision/lt-ref-self-async.base.stderr @@ -7,6 +7,12 @@ LL | async fn ref_self(&self, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn ref_self<'a>(&'a self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/lt-ref-self-async.rs:24:9 @@ -17,6 +23,12 @@ LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/lt-ref-self-async.rs:30:9 @@ -27,6 +39,12 @@ LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/lt-ref-self-async.rs:36:9 @@ -37,6 +55,12 @@ LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/lt-ref-self-async.rs:42:9 @@ -47,6 +71,12 @@ LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/lt-ref-self-async.rs:48:9 @@ -57,6 +87,12 @@ LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn box_pin_Self<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: aborting due to 6 previous errors diff --git a/src/test/ui/self/elision/lt-ref-self-async.nll.stderr b/src/test/ui/self/elision/lt-ref-self-async.nll.stderr index 2ba9a6596f6..1c889838e70 100644 --- a/src/test/ui/self/elision/lt-ref-self-async.nll.stderr +++ b/src/test/ui/self/elision/lt-ref-self-async.nll.stderr @@ -7,6 +7,11 @@ LL | async fn ref_self(&self, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn ref_self<'a>(&'a self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self-async.rs:24:9 @@ -17,6 +22,11 @@ LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self-async.rs:30:9 @@ -27,6 +37,11 @@ LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self-async.rs:36:9 @@ -37,6 +52,11 @@ LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self-async.rs:42:9 @@ -47,6 +67,11 @@ LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self-async.rs:48:9 @@ -57,6 +82,11 @@ LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn box_pin_Self<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: aborting due to 6 previous errors diff --git a/src/test/ui/self/elision/ref-mut-self-async.base.stderr b/src/test/ui/self/elision/ref-mut-self-async.base.stderr index 851337552c9..8ffc0d62242 100644 --- a/src/test/ui/self/elision/ref-mut-self-async.base.stderr +++ b/src/test/ui/self/elision/ref-mut-self-async.base.stderr @@ -7,6 +7,12 @@ LL | async fn ref_self(&mut self, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn ref_self<'a>(&'a mut self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-mut-self-async.rs:24:9 @@ -17,6 +23,12 @@ LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn ref_Self<'a>(self: &'a mut Self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-mut-self-async.rs:30:9 @@ -27,6 +39,12 @@ LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn box_ref_Self<'a>(self: Box<&'a mut Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-mut-self-async.rs:36:9 @@ -37,6 +55,12 @@ LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn pin_ref_Self<'a>(self: Pin<&'a mut Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-mut-self-async.rs:42:9 @@ -47,6 +71,12 @@ LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-mut-self-async.rs:48:9 @@ -57,6 +87,12 @@ LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: aborting due to 6 previous errors diff --git a/src/test/ui/self/elision/ref-mut-self-async.nll.stderr b/src/test/ui/self/elision/ref-mut-self-async.nll.stderr index cdd464039cd..9beafcd4ff9 100644 --- a/src/test/ui/self/elision/ref-mut-self-async.nll.stderr +++ b/src/test/ui/self/elision/ref-mut-self-async.nll.stderr @@ -7,6 +7,11 @@ LL | async fn ref_self(&mut self, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn ref_self<'a>(&'a mut self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self-async.rs:24:9 @@ -17,6 +22,11 @@ LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn ref_Self<'a>(self: &'a mut Self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self-async.rs:30:9 @@ -27,6 +37,11 @@ LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn box_ref_Self<'a>(self: Box<&'a mut Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self-async.rs:36:9 @@ -37,6 +52,11 @@ LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn pin_ref_Self<'a>(self: Pin<&'a mut Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self-async.rs:42:9 @@ -47,6 +67,11 @@ LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self-async.rs:48:9 @@ -57,6 +82,11 @@ LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: aborting due to 6 previous errors diff --git a/src/test/ui/self/elision/ref-mut-struct-async.base.stderr b/src/test/ui/self/elision/ref-mut-struct-async.base.stderr index 0de11c24875..fefb3fc1944 100644 --- a/src/test/ui/self/elision/ref-mut-struct-async.base.stderr +++ b/src/test/ui/self/elision/ref-mut-struct-async.base.stderr @@ -7,6 +7,12 @@ LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn ref_Struct<'a>(self: &'a mut Struct, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-mut-struct-async.rs:22:9 @@ -17,6 +23,12 @@ LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn box_ref_Struct<'a>(self: Box<&'a mut Struct>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-mut-struct-async.rs:28:9 @@ -27,6 +39,12 @@ LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn pin_ref_Struct<'a>(self: Pin<&'a mut Struct>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-mut-struct-async.rs:34:9 @@ -37,6 +55,12 @@ LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-mut-struct-async.rs:40:9 @@ -47,6 +71,12 @@ LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn box_pin_ref_Struct<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: aborting due to 5 previous errors diff --git a/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr b/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr index 0ef410c8df1..7fbecbe76a5 100644 --- a/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr +++ b/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr @@ -7,6 +7,11 @@ LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn ref_Struct<'a>(self: &'a mut Struct, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct-async.rs:22:9 @@ -17,6 +22,11 @@ LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn box_ref_Struct<'a>(self: Box<&'a mut Struct>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct-async.rs:28:9 @@ -27,6 +37,11 @@ LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn pin_ref_Struct<'a>(self: Pin<&'a mut Struct>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct-async.rs:34:9 @@ -37,6 +52,11 @@ LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct-async.rs:40:9 @@ -47,6 +67,11 @@ LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn box_pin_ref_Struct<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: aborting due to 5 previous errors diff --git a/src/test/ui/self/elision/ref-self-async.base.stderr b/src/test/ui/self/elision/ref-self-async.base.stderr index fa13b69bb21..2b142b089d5 100644 --- a/src/test/ui/self/elision/ref-self-async.base.stderr +++ b/src/test/ui/self/elision/ref-self-async.base.stderr @@ -7,6 +7,12 @@ LL | async fn ref_self(&self, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn ref_self<'a>(&'a self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-self-async.rs:34:9 @@ -17,6 +23,12 @@ LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-self-async.rs:40:9 @@ -27,6 +39,12 @@ LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-self-async.rs:46:9 @@ -37,6 +55,12 @@ LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-self-async.rs:52:9 @@ -47,6 +71,12 @@ LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-self-async.rs:58:9 @@ -57,6 +87,12 @@ LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-self-async.rs:64:9 @@ -67,6 +103,12 @@ LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn wrap_ref_Self_Self<'a>(self: Wrap<&'a Self, Self>, f: &'a u8) -> &u8 { + | ++++ ++ ++ error: aborting due to 7 previous errors diff --git a/src/test/ui/self/elision/ref-self-async.nll.stderr b/src/test/ui/self/elision/ref-self-async.nll.stderr index 77faaa86650..f4e531a817c 100644 --- a/src/test/ui/self/elision/ref-self-async.nll.stderr +++ b/src/test/ui/self/elision/ref-self-async.nll.stderr @@ -7,6 +7,11 @@ LL | async fn ref_self(&self, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn ref_self<'a>(&'a self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self-async.rs:34:9 @@ -17,6 +22,11 @@ LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self-async.rs:40:9 @@ -27,6 +37,11 @@ LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self-async.rs:46:9 @@ -37,6 +52,11 @@ LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self-async.rs:52:9 @@ -47,6 +67,11 @@ LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self-async.rs:58:9 @@ -57,6 +82,11 @@ LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self-async.rs:64:9 @@ -67,6 +97,11 @@ LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn wrap_ref_Self_Self<'a>(self: Wrap<&'a Self, Self>, f: &'a u8) -> &u8 { + | ++++ ++ ++ error: aborting due to 7 previous errors diff --git a/src/test/ui/self/elision/ref-struct-async.base.stderr b/src/test/ui/self/elision/ref-struct-async.base.stderr index 8da673d4435..88ddca89804 100644 --- a/src/test/ui/self/elision/ref-struct-async.base.stderr +++ b/src/test/ui/self/elision/ref-struct-async.base.stderr @@ -7,6 +7,12 @@ LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn ref_Struct<'a>(self: &'a Struct, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-struct-async.rs:22:9 @@ -17,6 +23,12 @@ LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn box_ref_Struct<'a>(self: Box<&'a Struct>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-struct-async.rs:28:9 @@ -27,6 +39,12 @@ LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn pin_ref_Struct<'a>(self: Pin<&'a Struct>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-struct-async.rs:34:9 @@ -37,6 +55,12 @@ LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error[E0623]: lifetime mismatch --> $DIR/ref-struct-async.rs:40:9 @@ -47,6 +71,12 @@ LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... LL | f | ^ ...but data from `f` is returned here + | + = note: each elided lifetime in input position becomes a distinct lifetime +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn box_pin_Struct<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: aborting due to 5 previous errors diff --git a/src/test/ui/self/elision/ref-struct-async.nll.stderr b/src/test/ui/self/elision/ref-struct-async.nll.stderr index ad07c70df87..83c20329c3d 100644 --- a/src/test/ui/self/elision/ref-struct-async.nll.stderr +++ b/src/test/ui/self/elision/ref-struct-async.nll.stderr @@ -7,6 +7,11 @@ LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn ref_Struct<'a>(self: &'a Struct, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct-async.rs:22:9 @@ -17,6 +22,11 @@ LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn box_ref_Struct<'a>(self: Box<&'a Struct>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct-async.rs:28:9 @@ -27,6 +37,11 @@ LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn pin_ref_Struct<'a>(self: Pin<&'a Struct>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct-async.rs:34:9 @@ -37,6 +52,11 @@ LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct-async.rs:40:9 @@ -47,6 +67,11 @@ LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ 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 | async fn box_pin_Struct<'a>(self: Box>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: aborting due to 5 previous errors