1
Fork 0

Inherit lifetimes for async fn instead of duplicating them.

This commit is contained in:
Camille GILLOT 2021-11-30 21:55:52 +01:00
parent 6499c5e7fc
commit a4da6308b7
22 changed files with 171 additions and 248 deletions

View file

@ -1659,11 +1659,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// When we create the opaque type for this async fn, it is going to have // When we create the opaque type for this async fn, it is going to have
// to capture all the lifetimes involved in the signature (including in the // to capture all the lifetimes involved in the signature (including in the
// return type). This is done by introducing lifetime parameters for: // return type). This is done by:
// //
// - all the explicitly declared lifetimes from the impl and function itself; // - making the opaque type inherit all lifetime parameters from its parent;
// - all the elided lifetimes in the fn arguments; // - make all the elided lifetimes in the fn arguments into parameters;
// - all the elided lifetimes in the return type. // - manually introducing parameters on the opaque type for elided
// lifetimes in the return type.
// //
// So for example in this snippet: // So for example in this snippet:
// //
@ -1679,14 +1680,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// we would create an opaque type like: // we would create an opaque type like:
// //
// ``` // ```
// type Bar<'a, 'b, '0, '1, '2> = impl Future<Output = &'2 u32>; // type Foo<'a>::bar<'b, '0, '1>::Bar<'2> = impl Future<Output = &'2 u32>;
// ``` // ```
// //
// and we would then desugar `bar` to the equivalent of: // and we would then desugar `bar` to the equivalent of:
// //
// ```rust // ```rust
// impl<'a> Foo<'a> { // impl<'a> Foo<'a> {
// fn bar<'b, '0, '1>(&'0 self, x: &'b Vec<f64>, y: &'1 str) -> Bar<'a, 'b, '0, '1, '_> // fn bar<'b, '0, '1>(&'0 self, x: &'b Vec<f64>, y: &'1 str) -> Bar<'_>
// } // }
// ``` // ```
// //
@ -1694,29 +1695,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// this is because the elided lifetimes from the return type // this is because the elided lifetimes from the return type
// should be figured out using the ordinary elision rules, and // should be figured out using the ordinary elision rules, and
// this desugaring achieves that. // this desugaring achieves that.
let mut lifetime_params = Vec::new();
debug!("lower_async_fn_ret_ty: in_scope_lifetimes={:#?}", self.in_scope_lifetimes);
debug!("lower_async_fn_ret_ty: lifetimes_to_define={:#?}", self.lifetimes_to_define);
// Calculate all the lifetimes that should be captured
// by the opaque type. This should include all in-scope
// lifetime parameters, including those defined in-band.
//
// `lifetime_params` is a vector of tuple (span, parameter name, lifetime name).
// Input lifetime like `'a` or `'1`:
let mut lifetime_params: Vec<_> = self
.in_scope_lifetimes
.iter()
.cloned()
.map(|name| (name.ident().span, name, hir::LifetimeName::Param(name)))
.chain(
self.lifetimes_to_define
.iter()
.map(|&(span, name)| (span, name, hir::LifetimeName::Param(name))),
)
.collect();
self.with_hir_id_owner(opaque_ty_node_id, |this| { self.with_hir_id_owner(opaque_ty_node_id, |this| {
// We have to be careful to get elision right here. The // We have to be careful to get elision right here. The
// idea is that we create a lifetime parameter for each // idea is that we create a lifetime parameter for each
@ -1735,16 +1714,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
debug!("lower_async_fn_ret_ty: future_bound={:#?}", future_bound); debug!("lower_async_fn_ret_ty: future_bound={:#?}", future_bound);
debug!("lower_async_fn_ret_ty: lifetimes_to_define={:#?}", lifetimes_to_define); debug!("lower_async_fn_ret_ty: lifetimes_to_define={:#?}", lifetimes_to_define);
lifetime_params.extend(
// Output lifetime like `'_`: // Output lifetime like `'_`:
lifetimes_to_define lifetime_params = lifetimes_to_define;
.into_iter()
.map(|(span, name)| (span, name, hir::LifetimeName::Implicit(false))),
);
debug!("lower_async_fn_ret_ty: lifetime_params={:#?}", lifetime_params); debug!("lower_async_fn_ret_ty: lifetime_params={:#?}", lifetime_params);
let generic_params = let generic_params =
this.arena.alloc_from_iter(lifetime_params.iter().map(|&(span, hir_name, _)| { this.arena.alloc_from_iter(lifetime_params.iter().map(|&(span, hir_name)| {
this.lifetime_to_generic_param(span, hir_name, opaque_ty_def_id) this.lifetime_to_generic_param(span, hir_name, opaque_ty_def_id)
})); }));
@ -1762,28 +1737,22 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
this.generate_opaque_type(opaque_ty_def_id, opaque_ty_item, span, opaque_ty_span) this.generate_opaque_type(opaque_ty_def_id, opaque_ty_item, span, opaque_ty_span)
}); });
// As documented above on the variable // We need to create the lifetime arguments to our opaque type.
// `input_lifetimes_count`, we need to create the lifetime // Continuing with our example, we're creating the type arguments
// arguments to our opaque type. Continuing with our example, // for the return type:
// we're creating the type arguments for the return type:
// //
// ``` // ```
// Bar<'a, 'b, '0, '1, '_> // For<'a>::bar<'b, '0, '1>::Bar<'_>
// ``` // ```
// //
// For the "input" lifetime parameters, we wish to create // For the "input" lifetime parameters are inherited automatically.
// references to the parameters themselves, including the // For the "output" lifetime parameters, we just want to generate `'_`.
// "implicit" ones created from parameter types (`'a`, `'b`,
// '`0`, `'1`).
//
// For the "output" lifetime parameters, we just want to
// generate `'_`.
let generic_args = let generic_args =
self.arena.alloc_from_iter(lifetime_params.into_iter().map(|(span, _, name)| { self.arena.alloc_from_iter(lifetime_params.into_iter().map(|(span, _)| {
GenericArg::Lifetime(hir::Lifetime { GenericArg::Lifetime(hir::Lifetime {
hir_id: self.next_id(), hir_id: self.next_id(),
span: self.lower_span(span), span: self.lower_span(span),
name, name: hir::LifetimeName::Implicit(false),
}) })
})); }));

View file

@ -276,7 +276,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
debug!(?concrete_ty); debug!(?concrete_ty);
let first_own_region = match opaque_defn.origin { let first_own_region = match opaque_defn.origin {
hir::OpaqueTyOrigin::FnReturn(..) | hir::OpaqueTyOrigin::AsyncFn(..) => { hir::OpaqueTyOrigin::FnReturn(..) => {
// We lower // We lower
// //
// fn foo<'l0..'ln>() -> impl Trait<'l0..'lm> // fn foo<'l0..'ln>() -> impl Trait<'l0..'lm>
@ -291,7 +291,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
} }
// These opaque type inherit all lifetime parameters from their // These opaque type inherit all lifetime parameters from their
// parent, so we have to check them all. // parent, so we have to check them all.
hir::OpaqueTyOrigin::TyAlias => 0, hir::OpaqueTyOrigin::AsyncFn(..) | hir::OpaqueTyOrigin::TyAlias => 0,
}; };
// For a case like `impl Foo<'a, 'b>`, we would generate a constraint // For a case like `impl Foo<'a, 'b>`, we would generate a constraint

View file

@ -729,9 +729,16 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
match item.kind { match item.kind {
hir::ItemKind::Fn(ref sig, ref generics, _) => { hir::ItemKind::Fn(ref sig, ref generics, _) => {
self.missing_named_lifetime_spots.push(generics.into()); self.missing_named_lifetime_spots.push(generics.into());
self.visit_early_late(None, item.hir_id(), &sig.decl, generics, |this| { self.visit_early_late(
None,
item.hir_id(),
&sig.decl,
generics,
sig.header.asyncness,
|this| {
intravisit::walk_item(this, item); intravisit::walk_item(this, item);
}); },
);
self.missing_named_lifetime_spots.pop(); self.missing_named_lifetime_spots.pop();
} }
@ -849,11 +856,16 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem<'tcx>) { fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem<'tcx>) {
match item.kind { match item.kind {
hir::ForeignItemKind::Fn(ref decl, _, ref generics) => { hir::ForeignItemKind::Fn(ref decl, _, ref generics) => self.visit_early_late(
self.visit_early_late(None, item.hir_id(), decl, generics, |this| { None,
item.hir_id(),
decl,
generics,
hir::IsAsync::NotAsync,
|this| {
intravisit::walk_foreign_item(this, item); intravisit::walk_foreign_item(this, item);
}) },
} ),
hir::ForeignItemKind::Static(..) => { hir::ForeignItemKind::Static(..) => {
intravisit::walk_foreign_item(self, item); intravisit::walk_foreign_item(self, item);
} }
@ -1130,6 +1142,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
trait_item.hir_id(), trait_item.hir_id(),
&sig.decl, &sig.decl,
&trait_item.generics, &trait_item.generics,
sig.header.asyncness,
|this| intravisit::walk_trait_item(this, trait_item), |this| intravisit::walk_trait_item(this, trait_item),
); );
self.missing_named_lifetime_spots.pop(); self.missing_named_lifetime_spots.pop();
@ -1199,6 +1212,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
impl_item.hir_id(), impl_item.hir_id(),
&sig.decl, &sig.decl,
&impl_item.generics, &impl_item.generics,
sig.header.asyncness,
|this| intravisit::walk_impl_item(this, impl_item), |this| intravisit::walk_impl_item(this, impl_item),
); );
self.missing_named_lifetime_spots.pop(); self.missing_named_lifetime_spots.pop();
@ -2159,11 +2173,15 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
hir_id: hir::HirId, hir_id: hir::HirId,
decl: &'tcx hir::FnDecl<'tcx>, decl: &'tcx hir::FnDecl<'tcx>,
generics: &'tcx hir::Generics<'tcx>, generics: &'tcx hir::Generics<'tcx>,
asyncness: hir::IsAsync,
walk: F, walk: F,
) where ) where
F: for<'b, 'c> FnOnce(&'b mut LifetimeContext<'c, 'tcx>), F: for<'b, 'c> FnOnce(&'b mut LifetimeContext<'c, 'tcx>),
{ {
// Async fns need all their lifetime parameters to be early bound.
if asyncness != hir::IsAsync::Async {
insert_late_bound_lifetimes(self.map, decl, generics); insert_late_bound_lifetimes(self.map, decl, generics);
}
// Find the start of nested early scopes, e.g., in methods. // Find the start of nested early scopes, e.g., in methods.
let mut next_early_index = 0; let mut next_early_index = 0;

View file

@ -2408,16 +2408,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let def_id = item_id.def_id.to_def_id(); let def_id = item_id.def_id.to_def_id();
match opaque_ty.kind { match opaque_ty.kind {
hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => self hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => {
.impl_trait_ty_to_ty( let replace_parent_lifetimes =
def_id, matches!(origin, hir::OpaqueTyOrigin::FnReturn(..));
lifetimes, self.impl_trait_ty_to_ty(def_id, lifetimes, replace_parent_lifetimes)
matches!( }
origin,
hir::OpaqueTyOrigin::FnReturn(..)
| hir::OpaqueTyOrigin::AsyncFn(..)
),
),
ref i => bug!("`impl Trait` pointed to non-opaque type?? {:#?}", i), ref i => bug!("`impl Trait` pointed to non-opaque type?? {:#?}", i),
} }
} }

View file

@ -535,10 +535,8 @@ pub(super) fn check_opaque_for_inheriting_lifetimes<'tcx>(
} }
} }
if let ItemKind::OpaqueTy(hir::OpaqueTy { if let ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::FnReturn(..), .. }) =
origin: hir::OpaqueTyOrigin::AsyncFn(..) | hir::OpaqueTyOrigin::FnReturn(..), item.kind
..
}) = item.kind
{ {
let mut visitor = ProhibitOpaqueVisitor { let mut visitor = ProhibitOpaqueVisitor {
opaque_identity_ty: tcx.mk_opaque( opaque_identity_ty: tcx.mk_opaque(
@ -560,20 +558,13 @@ pub(super) fn check_opaque_for_inheriting_lifetimes<'tcx>(
if let Some(ty) = prohibit_opaque.break_value() { if let Some(ty) = prohibit_opaque.break_value() {
visitor.visit_item(&item); visitor.visit_item(&item);
let is_async = match item.kind {
ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => {
matches!(origin, hir::OpaqueTyOrigin::AsyncFn(..))
}
_ => unreachable!(),
};
let mut err = struct_span_err!( let mut err = struct_span_err!(
tcx.sess, tcx.sess,
span, span,
E0760, E0760,
"`{}` return type cannot contain a projection or `Self` that references lifetimes from \ "`impl Trait` return type cannot contain a projection or `Self` that references lifetimes from \
a parent scope", a parent scope",
if is_async { "async fn" } else { "impl Trait" },
); );
for (span, name) in visitor.selftys { for (span, name) in visitor.selftys {

View file

@ -2162,8 +2162,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
generics generics
} }
ItemKind::OpaqueTy(OpaqueTy { ItemKind::OpaqueTy(OpaqueTy {
origin: hir::OpaqueTyOrigin::AsyncFn(..) | hir::OpaqueTyOrigin::FnReturn(..), origin: hir::OpaqueTyOrigin::FnReturn(..), ..
..
}) => { }) => {
// return-position impl trait // return-position impl trait
// //
@ -2183,7 +2182,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
} }
ItemKind::OpaqueTy(OpaqueTy { ItemKind::OpaqueTy(OpaqueTy {
ref generics, ref generics,
origin: hir::OpaqueTyOrigin::TyAlias, origin: hir::OpaqueTyOrigin::AsyncFn(..) | hir::OpaqueTyOrigin::TyAlias,
.. ..
}) => { }) => {
// type-alias impl trait // type-alias impl trait

View file

@ -8,7 +8,6 @@ pub struct Foo<'a> {
impl<'a> Foo<'a> { impl<'a> Foo<'a> {
pub async fn new(_bar: &'a i32) -> Self { pub async fn new(_bar: &'a i32) -> Self {
//~^ ERROR `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
Foo { Foo {
bar: &22 bar: &22
} }
@ -19,6 +18,7 @@ async fn foo() {
let x = { let x = {
let bar = 22; let bar = 22;
Foo::new(&bar).await Foo::new(&bar).await
//~^ ERROR `bar` does not live long enough [E0597]
}; };
drop(x); drop(x);
} }

View file

@ -1,9 +1,15 @@
error[E0760]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope error[E0597]: `bar` does not live long enough
--> $DIR/issue-61949-self-return-type.rs:10:40 --> $DIR/issue-61949-self-return-type.rs:20:18
| |
LL | pub async fn new(_bar: &'a i32) -> Self { LL | let x = {
| ^^^^ help: consider spelling out the type instead: `Foo<'a>` | - borrow later stored here
LL | let bar = 22;
LL | Foo::new(&bar).await
| ^^^^ borrowed value does not live long enough
LL |
LL | };
| - `bar` dropped here while still borrowed
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0760`. For more information about this error, try `rustc --explain E0597`.

View file

@ -1,14 +1,10 @@
error[E0506]: cannot assign to `*x` because it is borrowed error[E0506]: cannot assign to `*x` because it is borrowed
--> $DIR/issue-74072-lifetime-name-annotations.rs:9:5 --> $DIR/issue-74072-lifetime-name-annotations.rs:9:5
| |
LL | pub async fn async_fn(x: &mut i32) -> &i32 {
| - let's call the lifetime of this reference `'1`
LL | let y = &*x; LL | let y = &*x;
| --- borrow of `*x` occurs here | --- borrow of `*x` occurs here
LL | *x += 1; LL | *x += 1;
| ^^^^^^^ assignment to borrowed `*x` occurs here | ^^^^^^^ assignment to borrowed `*x` occurs here
LL | y
| - returning this value requires that `*x` is borrowed for `'1`
error[E0506]: cannot assign to `*x` because it is borrowed error[E0506]: cannot assign to `*x` because it is borrowed
--> $DIR/issue-74072-lifetime-name-annotations.rs:16:9 --> $DIR/issue-74072-lifetime-name-annotations.rs:16:9

View file

@ -1,14 +1,10 @@
error[E0506]: cannot assign to `*x` because it is borrowed error[E0506]: cannot assign to `*x` because it is borrowed
--> $DIR/issue-75785-confusing-named-region.rs:9:5 --> $DIR/issue-75785-confusing-named-region.rs:9:5
| |
LL | pub async fn async_fn(x: &mut i32) -> (&i32, &i32) {
| - let's call the lifetime of this reference `'1`
LL | let y = &*x; LL | let y = &*x;
| --- borrow of `*x` occurs here | --- borrow of `*x` occurs here
LL | *x += 1; LL | *x += 1;
| ^^^^^^^ assignment to borrowed `*x` occurs here | ^^^^^^^ assignment to borrowed `*x` occurs here
LL | (&32, y)
| -------- returning this value requires that `*x` is borrowed for `'1`
error: aborting due to previous error error: aborting due to previous error

View file

@ -2,12 +2,10 @@ error[E0623]: lifetime mismatch
--> $DIR/issue-63388-1.rs:14:9 --> $DIR/issue-63388-1.rs:14:9
| |
LL | &'a self, foo: &dyn Foo LL | &'a self, foo: &dyn Foo
| -------- this parameter and the return type are declared with different lifetimes... | -------- -------- these two types are declared with different lifetimes...
LL | ) -> &dyn Foo ...
| --------
LL | {
LL | foo LL | foo
| ^^^ ...but data from `foo` is returned here | ^^^ ...but data from `foo` flows into `self` here
error: aborting due to previous error error: aborting due to previous error

View file

@ -1,10 +1,10 @@
// check-pass
// edition:2018 // edition:2018
struct S<'a>(&'a i32); struct S<'a>(&'a i32);
impl<'a> S<'a> { impl<'a> S<'a> {
async fn new(i: &'a i32) -> Result<Self, ()> { async fn new(i: &'a i32) -> Result<Self, ()> {
//~^ ERROR: `async fn`
Ok(S(&22)) Ok(S(&22))
} }
} }

View file

@ -1,11 +0,0 @@
error[E0760]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
--> $DIR/issue-78600.rs:6:33
|
LL | async fn new(i: &'a i32) -> Result<Self, ()> {
| ^^^^^^^----^^^^^
| |
| help: consider spelling out the type instead: `S<'a>`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0760`.

View file

@ -2,10 +2,9 @@ error[E0623]: lifetime mismatch
--> $DIR/ret-impl-trait-one.rs:10:65 --> $DIR/ret-impl-trait-one.rs:10:65
| |
LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b { LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b {
| ------ ^^^^^^^^^^^^^^^^^^^ | ------ ------ ^^^^^^^^^^^^^^^^^^^ ...but data from `a` flows into `b` here
| | | | |
| | ...but data from `a` is returned here | these two types are declared with different lifetimes...
| this parameter and the return type are declared with different lifetimes...
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
--> $DIR/ret-impl-trait-one.rs:16:65 --> $DIR/ret-impl-trait-one.rs:16:65

View file

@ -10,10 +10,13 @@
// Even wrong cases don't cause errors because async functions are desugared with all lifetimes // Even wrong cases don't cause errors because async functions are desugared with all lifetimes
// involved in the signature. So, we cannot predict what lifetimes are unused in async function. // involved in the signature. So, we cannot predict what lifetimes are unused in async function.
async fn async_wrong_without_args<'a>() {} async fn async_wrong_without_args<'a>() {}
//~^ ERROR lifetime parameter `'a` never used [unused_lifetimes]
async fn async_wrong_1_lifetime<'a>(_: &i32) {} async fn async_wrong_1_lifetime<'a>(_: &i32) {}
//~^ ERROR lifetime parameter `'a` never used [unused_lifetimes]
async fn async_wrong_2_lifetimes<'a, 'b>(_: &'a i32, _: &i32) {} async fn async_wrong_2_lifetimes<'a, 'b>(_: &'a i32, _: &i32) {}
//~^ ERROR lifetime parameter `'b` never used [unused_lifetimes]
async fn async_right_1_lifetime<'a>(_: &'a i32) {} async fn async_right_1_lifetime<'a>(_: &'a i32) {}

View file

@ -1,7 +1,7 @@
error: lifetime parameter `'a` never used error: lifetime parameter `'a` never used
--> $DIR/unused-lifetime.rs:31:23 --> $DIR/unused-lifetime.rs:12:35
| |
LL | fn wrong_without_args<'a>() {} LL | async fn async_wrong_without_args<'a>() {}
| -^^- help: elide the unused lifetime | -^^- help: elide the unused lifetime
| |
note: the lint level is defined here note: the lint level is defined here
@ -11,18 +11,40 @@ LL | #![deny(unused_lifetimes)]
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
error: lifetime parameter `'a` never used error: lifetime parameter `'a` never used
--> $DIR/unused-lifetime.rs:33:21 --> $DIR/unused-lifetime.rs:15:33
|
LL | async fn async_wrong_1_lifetime<'a>(_: &i32) {}
| ^^-----
| |
| help: elide the unused lifetime
error: lifetime parameter `'b` never used
--> $DIR/unused-lifetime.rs:18:38
|
LL | async fn async_wrong_2_lifetimes<'a, 'b>(_: &'a i32, _: &i32) {}
| ^^-----------------
| |
| help: elide the unused lifetime
error: lifetime parameter `'a` never used
--> $DIR/unused-lifetime.rs:34:23
|
LL | fn wrong_without_args<'a>() {}
| -^^- help: elide the unused lifetime
error: lifetime parameter `'a` never used
--> $DIR/unused-lifetime.rs:36:21
| |
LL | fn wrong_1_lifetime<'a>(_: &i32) {} LL | fn wrong_1_lifetime<'a>(_: &i32) {}
| -^^- help: elide the unused lifetime | -^^- help: elide the unused lifetime
error: lifetime parameter `'b` never used error: lifetime parameter `'b` never used
--> $DIR/unused-lifetime.rs:35:26 --> $DIR/unused-lifetime.rs:38:26
| |
LL | fn wrong_2_lifetimes<'a, 'b>(_: &'a i32, _: &i32) {} LL | fn wrong_2_lifetimes<'a, 'b>(_: &'a i32, _: &i32) {}
| --^^ | --^^
| | | |
| help: elide the unused lifetime | help: elide the unused lifetime
error: aborting due to 3 previous errors error: aborting due to 6 previous errors

View file

@ -2,25 +2,25 @@ error[E0623]: lifetime mismatch
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:8:52 --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:8:52
| |
LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f }
| ---- ---- ^ ...but data from `f` is returned here | ---- ---- ^ ...but data from `f` flows into `self` here
| | | |
| this parameter and the return type are declared with different lifetimes... | these two types are declared with different lifetimes...
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:11:82 --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:11:82
| |
LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) }
| ---- ----------------- ^ ...but data from `f` is returned here | ----- ---- ^ ...but data from `f` flows into `self` here
| | | |
| this parameter and the return type are declared with different lifetimes... | these two types are declared with different lifetimes...
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:17:64 --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:17:64
| |
LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg }
| ------ --- ^^^ ...but data from `arg` is returned here | ----- ------ ^^^ ...but data from `arg` flows into `self` here
| | | |
| this parameter and the return type are declared with different lifetimes... | these two types are declared with different lifetimes...
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View file

@ -2,61 +2,49 @@ error[E0623]: lifetime mismatch
--> $DIR/lt-ref-self-async.rs:13:9 --> $DIR/lt-ref-self-async.rs:13:9
| |
LL | async fn ref_self(&self, f: &u32) -> &u32 { LL | async fn ref_self(&self, f: &u32) -> &u32 {
| ---- ---- | ----- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/lt-ref-self-async.rs:19:9 --> $DIR/lt-ref-self-async.rs:19:9
| |
LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 {
| ---- ---- | ----- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/lt-ref-self-async.rs:23:9 --> $DIR/lt-ref-self-async.rs:23:9
| |
LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
| ---- ---- | ----- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/lt-ref-self-async.rs:27:9 --> $DIR/lt-ref-self-async.rs:27:9
| |
LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
| ---- ---- | ----- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/lt-ref-self-async.rs:31:9 --> $DIR/lt-ref-self-async.rs:31:9
| |
LL | async fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 { LL | async fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
| ---- ---- | ----- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/lt-ref-self-async.rs:35:9 --> $DIR/lt-ref-self-async.rs:35:9
| |
LL | async fn box_pin_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 { LL | async fn box_pin_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
| ---- ---- | ----- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error: aborting due to 6 previous errors error: aborting due to 6 previous errors

View file

@ -2,61 +2,49 @@ error[E0623]: lifetime mismatch
--> $DIR/ref-mut-self-async.rs:13:9 --> $DIR/ref-mut-self-async.rs:13:9
| |
LL | async fn ref_self(&mut self, f: &u32) -> &u32 { LL | async fn ref_self(&mut self, f: &u32) -> &u32 {
| ---- ---- | --------- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-mut-self-async.rs:19:9 --> $DIR/ref-mut-self-async.rs:19:9
| |
LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 {
| ---- ---- | --------- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-mut-self-async.rs:23:9 --> $DIR/ref-mut-self-async.rs:23:9
| |
LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 {
| ---- ---- | --------- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-mut-self-async.rs:27:9 --> $DIR/ref-mut-self-async.rs:27:9
| |
LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 {
| ---- ---- | --------- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-mut-self-async.rs:31:9 --> $DIR/ref-mut-self-async.rs:31:9
| |
LL | async fn box_box_ref_Self(self: Box<Box<&mut Self>>, f: &u32) -> &u32 { LL | async fn box_box_ref_Self(self: Box<Box<&mut Self>>, f: &u32) -> &u32 {
| ---- ---- | --------- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-mut-self-async.rs:35:9 --> $DIR/ref-mut-self-async.rs:35:9
| |
LL | async fn box_pin_ref_Self(self: Box<Pin<&mut Self>>, f: &u32) -> &u32 { LL | async fn box_pin_ref_Self(self: Box<Pin<&mut Self>>, f: &u32) -> &u32 {
| ---- ---- | --------- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error: aborting due to 6 previous errors error: aborting due to 6 previous errors

View file

@ -2,51 +2,41 @@ error[E0623]: lifetime mismatch
--> $DIR/ref-mut-struct-async.rs:13:9 --> $DIR/ref-mut-struct-async.rs:13:9
| |
LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 {
| ---- ---- | ----------- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-mut-struct-async.rs:17:9 --> $DIR/ref-mut-struct-async.rs:17:9
| |
LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 {
| ---- ---- | ----------- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-mut-struct-async.rs:21:9 --> $DIR/ref-mut-struct-async.rs:21:9
| |
LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 {
| ---- ---- | ----------- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-mut-struct-async.rs:25:9 --> $DIR/ref-mut-struct-async.rs:25:9
| |
LL | async fn box_box_ref_Struct(self: Box<Box<&mut Struct>>, f: &u32) -> &u32 { LL | async fn box_box_ref_Struct(self: Box<Box<&mut Struct>>, f: &u32) -> &u32 {
| ---- ---- | ----------- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-mut-struct-async.rs:29:9 --> $DIR/ref-mut-struct-async.rs:29:9
| |
LL | async fn box_pin_ref_Struct(self: Box<Pin<&mut Struct>>, f: &u32) -> &u32 { LL | async fn box_pin_ref_Struct(self: Box<Pin<&mut Struct>>, f: &u32) -> &u32 {
| ---- ---- | ----------- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error: aborting due to 5 previous errors error: aborting due to 5 previous errors

View file

@ -2,71 +2,57 @@ error[E0623]: lifetime mismatch
--> $DIR/ref-self-async.rs:23:9 --> $DIR/ref-self-async.rs:23:9
| |
LL | async fn ref_self(&self, f: &u32) -> &u32 { LL | async fn ref_self(&self, f: &u32) -> &u32 {
| ---- ---- | ----- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-self-async.rs:29:9 --> $DIR/ref-self-async.rs:29:9
| |
LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 {
| ---- ---- | ----- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-self-async.rs:33:9 --> $DIR/ref-self-async.rs:33:9
| |
LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
| ---- ---- | ----- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-self-async.rs:37:9 --> $DIR/ref-self-async.rs:37:9
| |
LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
| ---- ---- | ----- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-self-async.rs:41:9 --> $DIR/ref-self-async.rs:41:9
| |
LL | async fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 { LL | async fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
| ---- ---- | ----- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-self-async.rs:45:9 --> $DIR/ref-self-async.rs:45:9
| |
LL | async fn box_pin_ref_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 { LL | async fn box_pin_ref_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
| ---- ---- | ----- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-self-async.rs:49:9 --> $DIR/ref-self-async.rs:49:9
| |
LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 {
| --- --- | ----- --- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error: aborting due to 7 previous errors error: aborting due to 7 previous errors

View file

@ -2,51 +2,41 @@ error[E0623]: lifetime mismatch
--> $DIR/ref-struct-async.rs:13:9 --> $DIR/ref-struct-async.rs:13:9
| |
LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
| ---- ---- | ------- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-struct-async.rs:17:9 --> $DIR/ref-struct-async.rs:17:9
| |
LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 {
| ---- ---- | ------- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-struct-async.rs:21:9 --> $DIR/ref-struct-async.rs:21:9
| |
LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 {
| ---- ---- | ------- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-struct-async.rs:25:9 --> $DIR/ref-struct-async.rs:25:9
| |
LL | async fn box_box_ref_Struct(self: Box<Box<&Struct>>, f: &u32) -> &u32 { LL | async fn box_box_ref_Struct(self: Box<Box<&Struct>>, f: &u32) -> &u32 {
| ---- ---- | ------- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/ref-struct-async.rs:29:9 --> $DIR/ref-struct-async.rs:29:9
| |
LL | async fn box_pin_Struct(self: Box<Pin<&Struct>>, f: &u32) -> &u32 { LL | async fn box_pin_Struct(self: Box<Pin<&Struct>>, f: &u32) -> &u32 {
| ---- ---- | ------- ---- these two types are declared with different lifetimes...
| |
| this parameter and the return type are declared with different lifetimes...
LL | f LL | f
| ^ ...but data from `f` is returned here | ^ ...but data from `f` flows into `self` here
error: aborting due to 5 previous errors error: aborting due to 5 previous errors