Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a4da630

Browse files
committedFeb 12, 2022
Inherit lifetimes for async fn instead of duplicating them.
1 parent 6499c5e commit a4da630

22 files changed

+171
-248
lines changed
 

‎compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 19 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,11 +1659,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
16591659

16601660
// When we create the opaque type for this async fn, it is going to have
16611661
// to capture all the lifetimes involved in the signature (including in the
1662-
// return type). This is done by introducing lifetime parameters for:
1662+
// return type). This is done by:
16631663
//
1664-
// - all the explicitly declared lifetimes from the impl and function itself;
1665-
// - all the elided lifetimes in the fn arguments;
1666-
// - all the elided lifetimes in the return type.
1664+
// - making the opaque type inherit all lifetime parameters from its parent;
1665+
// - make all the elided lifetimes in the fn arguments into parameters;
1666+
// - manually introducing parameters on the opaque type for elided
1667+
// lifetimes in the return type.
16671668
//
16681669
// So for example in this snippet:
16691670
//
@@ -1679,44 +1680,22 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
16791680
// we would create an opaque type like:
16801681
//
16811682
// ```
1682-
// type Bar<'a, 'b, '0, '1, '2> = impl Future<Output = &'2 u32>;
1683+
// type Foo<'a>::bar<'b, '0, '1>::Bar<'2> = impl Future<Output = &'2 u32>;
16831684
// ```
16841685
//
16851686
// and we would then desugar `bar` to the equivalent of:
16861687
//
16871688
// ```rust
16881689
// impl<'a> Foo<'a> {
1689-
// fn bar<'b, '0, '1>(&'0 self, x: &'b Vec<f64>, y: &'1 str) -> Bar<'a, 'b, '0, '1, '_>
1690+
// fn bar<'b, '0, '1>(&'0 self, x: &'b Vec<f64>, y: &'1 str) -> Bar<'_>
16901691
// }
16911692
// ```
16921693
//
16931694
// Note that the final parameter to `Bar` is `'_`, not `'2` --
16941695
// this is because the elided lifetimes from the return type
16951696
// should be figured out using the ordinary elision rules, and
16961697
// this desugaring achieves that.
1697-
1698-
debug!("lower_async_fn_ret_ty: in_scope_lifetimes={:#?}", self.in_scope_lifetimes);
1699-
debug!("lower_async_fn_ret_ty: lifetimes_to_define={:#?}", self.lifetimes_to_define);
1700-
1701-
// Calculate all the lifetimes that should be captured
1702-
// by the opaque type. This should include all in-scope
1703-
// lifetime parameters, including those defined in-band.
1704-
//
1705-
// `lifetime_params` is a vector of tuple (span, parameter name, lifetime name).
1706-
1707-
// Input lifetime like `'a` or `'1`:
1708-
let mut lifetime_params: Vec<_> = self
1709-
.in_scope_lifetimes
1710-
.iter()
1711-
.cloned()
1712-
.map(|name| (name.ident().span, name, hir::LifetimeName::Param(name)))
1713-
.chain(
1714-
self.lifetimes_to_define
1715-
.iter()
1716-
.map(|&(span, name)| (span, name, hir::LifetimeName::Param(name))),
1717-
)
1718-
.collect();
1719-
1698+
let mut lifetime_params = Vec::new();
17201699
self.with_hir_id_owner(opaque_ty_node_id, |this| {
17211700
// We have to be careful to get elision right here. The
17221701
// idea is that we create a lifetime parameter for each
@@ -1735,16 +1714,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17351714
debug!("lower_async_fn_ret_ty: future_bound={:#?}", future_bound);
17361715
debug!("lower_async_fn_ret_ty: lifetimes_to_define={:#?}", lifetimes_to_define);
17371716

1738-
lifetime_params.extend(
1739-
// Output lifetime like `'_`:
1740-
lifetimes_to_define
1741-
.into_iter()
1742-
.map(|(span, name)| (span, name, hir::LifetimeName::Implicit(false))),
1743-
);
1717+
// Output lifetime like `'_`:
1718+
lifetime_params = lifetimes_to_define;
17441719
debug!("lower_async_fn_ret_ty: lifetime_params={:#?}", lifetime_params);
17451720

17461721
let generic_params =
1747-
this.arena.alloc_from_iter(lifetime_params.iter().map(|&(span, hir_name, _)| {
1722+
this.arena.alloc_from_iter(lifetime_params.iter().map(|&(span, hir_name)| {
17481723
this.lifetime_to_generic_param(span, hir_name, opaque_ty_def_id)
17491724
}));
17501725

@@ -1762,28 +1737,22 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17621737
this.generate_opaque_type(opaque_ty_def_id, opaque_ty_item, span, opaque_ty_span)
17631738
});
17641739

1765-
// As documented above on the variable
1766-
// `input_lifetimes_count`, we need to create the lifetime
1767-
// arguments to our opaque type. Continuing with our example,
1768-
// we're creating the type arguments for the return type:
1740+
// We need to create the lifetime arguments to our opaque type.
1741+
// Continuing with our example, we're creating the type arguments
1742+
// for the return type:
17691743
//
17701744
// ```
1771-
// Bar<'a, 'b, '0, '1, '_>
1745+
// For<'a>::bar<'b, '0, '1>::Bar<'_>
17721746
// ```
17731747
//
1774-
// For the "input" lifetime parameters, we wish to create
1775-
// references to the parameters themselves, including the
1776-
// "implicit" ones created from parameter types (`'a`, `'b`,
1777-
// '`0`, `'1`).
1778-
//
1779-
// For the "output" lifetime parameters, we just want to
1780-
// generate `'_`.
1748+
// For the "input" lifetime parameters are inherited automatically.
1749+
// For the "output" lifetime parameters, we just want to generate `'_`.
17811750
let generic_args =
1782-
self.arena.alloc_from_iter(lifetime_params.into_iter().map(|(span, _, name)| {
1751+
self.arena.alloc_from_iter(lifetime_params.into_iter().map(|(span, _)| {
17831752
GenericArg::Lifetime(hir::Lifetime {
17841753
hir_id: self.next_id(),
17851754
span: self.lower_span(span),
1786-
name,
1755+
name: hir::LifetimeName::Implicit(false),
17871756
})
17881757
}));
17891758

‎compiler/rustc_infer/src/infer/opaque_types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
276276
debug!(?concrete_ty);
277277

278278
let first_own_region = match opaque_defn.origin {
279-
hir::OpaqueTyOrigin::FnReturn(..) | hir::OpaqueTyOrigin::AsyncFn(..) => {
279+
hir::OpaqueTyOrigin::FnReturn(..) => {
280280
// We lower
281281
//
282282
// fn foo<'l0..'ln>() -> impl Trait<'l0..'lm>
@@ -291,7 +291,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
291291
}
292292
// These opaque type inherit all lifetime parameters from their
293293
// parent, so we have to check them all.
294-
hir::OpaqueTyOrigin::TyAlias => 0,
294+
hir::OpaqueTyOrigin::AsyncFn(..) | hir::OpaqueTyOrigin::TyAlias => 0,
295295
};
296296

297297
// For a case like `impl Foo<'a, 'b>`, we would generate a constraint

‎compiler/rustc_resolve/src/late/lifetimes.rs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -729,9 +729,16 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
729729
match item.kind {
730730
hir::ItemKind::Fn(ref sig, ref generics, _) => {
731731
self.missing_named_lifetime_spots.push(generics.into());
732-
self.visit_early_late(None, item.hir_id(), &sig.decl, generics, |this| {
733-
intravisit::walk_item(this, item);
734-
});
732+
self.visit_early_late(
733+
None,
734+
item.hir_id(),
735+
&sig.decl,
736+
generics,
737+
sig.header.asyncness,
738+
|this| {
739+
intravisit::walk_item(this, item);
740+
},
741+
);
735742
self.missing_named_lifetime_spots.pop();
736743
}
737744

@@ -849,11 +856,16 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
849856

850857
fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem<'tcx>) {
851858
match item.kind {
852-
hir::ForeignItemKind::Fn(ref decl, _, ref generics) => {
853-
self.visit_early_late(None, item.hir_id(), decl, generics, |this| {
859+
hir::ForeignItemKind::Fn(ref decl, _, ref generics) => self.visit_early_late(
860+
None,
861+
item.hir_id(),
862+
decl,
863+
generics,
864+
hir::IsAsync::NotAsync,
865+
|this| {
854866
intravisit::walk_foreign_item(this, item);
855-
})
856-
}
867+
},
868+
),
857869
hir::ForeignItemKind::Static(..) => {
858870
intravisit::walk_foreign_item(self, item);
859871
}
@@ -1130,6 +1142,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
11301142
trait_item.hir_id(),
11311143
&sig.decl,
11321144
&trait_item.generics,
1145+
sig.header.asyncness,
11331146
|this| intravisit::walk_trait_item(this, trait_item),
11341147
);
11351148
self.missing_named_lifetime_spots.pop();
@@ -1199,6 +1212,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
11991212
impl_item.hir_id(),
12001213
&sig.decl,
12011214
&impl_item.generics,
1215+
sig.header.asyncness,
12021216
|this| intravisit::walk_impl_item(this, impl_item),
12031217
);
12041218
self.missing_named_lifetime_spots.pop();
@@ -2159,11 +2173,15 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
21592173
hir_id: hir::HirId,
21602174
decl: &'tcx hir::FnDecl<'tcx>,
21612175
generics: &'tcx hir::Generics<'tcx>,
2176+
asyncness: hir::IsAsync,
21622177
walk: F,
21632178
) where
21642179
F: for<'b, 'c> FnOnce(&'b mut LifetimeContext<'c, 'tcx>),
21652180
{
2166-
insert_late_bound_lifetimes(self.map, decl, generics);
2181+
// Async fns need all their lifetime parameters to be early bound.
2182+
if asyncness != hir::IsAsync::Async {
2183+
insert_late_bound_lifetimes(self.map, decl, generics);
2184+
}
21672185

21682186
// Find the start of nested early scopes, e.g., in methods.
21692187
let mut next_early_index = 0;

‎compiler/rustc_typeck/src/astconv/mod.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2408,16 +2408,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
24082408
let def_id = item_id.def_id.to_def_id();
24092409

24102410
match opaque_ty.kind {
2411-
hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => self
2412-
.impl_trait_ty_to_ty(
2413-
def_id,
2414-
lifetimes,
2415-
matches!(
2416-
origin,
2417-
hir::OpaqueTyOrigin::FnReturn(..)
2418-
| hir::OpaqueTyOrigin::AsyncFn(..)
2419-
),
2420-
),
2411+
hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => {
2412+
let replace_parent_lifetimes =
2413+
matches!(origin, hir::OpaqueTyOrigin::FnReturn(..));
2414+
self.impl_trait_ty_to_ty(def_id, lifetimes, replace_parent_lifetimes)
2415+
}
24212416
ref i => bug!("`impl Trait` pointed to non-opaque type?? {:#?}", i),
24222417
}
24232418
}

‎compiler/rustc_typeck/src/check/check.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,8 @@ pub(super) fn check_opaque_for_inheriting_lifetimes<'tcx>(
535535
}
536536
}
537537

538-
if let ItemKind::OpaqueTy(hir::OpaqueTy {
539-
origin: hir::OpaqueTyOrigin::AsyncFn(..) | hir::OpaqueTyOrigin::FnReturn(..),
540-
..
541-
}) = item.kind
538+
if let ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::FnReturn(..), .. }) =
539+
item.kind
542540
{
543541
let mut visitor = ProhibitOpaqueVisitor {
544542
opaque_identity_ty: tcx.mk_opaque(
@@ -560,20 +558,13 @@ pub(super) fn check_opaque_for_inheriting_lifetimes<'tcx>(
560558

561559
if let Some(ty) = prohibit_opaque.break_value() {
562560
visitor.visit_item(&item);
563-
let is_async = match item.kind {
564-
ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => {
565-
matches!(origin, hir::OpaqueTyOrigin::AsyncFn(..))
566-
}
567-
_ => unreachable!(),
568-
};
569561

570562
let mut err = struct_span_err!(
571563
tcx.sess,
572564
span,
573565
E0760,
574-
"`{}` return type cannot contain a projection or `Self` that references lifetimes from \
566+
"`impl Trait` return type cannot contain a projection or `Self` that references lifetimes from \
575567
a parent scope",
576-
if is_async { "async fn" } else { "impl Trait" },
577568
);
578569

579570
for (span, name) in visitor.selftys {

‎compiler/rustc_typeck/src/collect.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,8 +2162,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
21622162
generics
21632163
}
21642164
ItemKind::OpaqueTy(OpaqueTy {
2165-
origin: hir::OpaqueTyOrigin::AsyncFn(..) | hir::OpaqueTyOrigin::FnReturn(..),
2166-
..
2165+
origin: hir::OpaqueTyOrigin::FnReturn(..), ..
21672166
}) => {
21682167
// return-position impl trait
21692168
//
@@ -2183,7 +2182,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
21832182
}
21842183
ItemKind::OpaqueTy(OpaqueTy {
21852184
ref generics,
2186-
origin: hir::OpaqueTyOrigin::TyAlias,
2185+
origin: hir::OpaqueTyOrigin::AsyncFn(..) | hir::OpaqueTyOrigin::TyAlias,
21872186
..
21882187
}) => {
21892188
// type-alias impl trait

‎src/test/ui/async-await/issue-61949-self-return-type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ pub struct Foo<'a> {
88

99
impl<'a> Foo<'a> {
1010
pub async fn new(_bar: &'a i32) -> Self {
11-
//~^ ERROR `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
1211
Foo {
1312
bar: &22
1413
}
@@ -19,6 +18,7 @@ async fn foo() {
1918
let x = {
2019
let bar = 22;
2120
Foo::new(&bar).await
21+
//~^ ERROR `bar` does not live long enough [E0597]
2222
};
2323
drop(x);
2424
}
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
error[E0760]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
2-
--> $DIR/issue-61949-self-return-type.rs:10:40
1+
error[E0597]: `bar` does not live long enough
2+
--> $DIR/issue-61949-self-return-type.rs:20:18
33
|
4-
LL | pub async fn new(_bar: &'a i32) -> Self {
5-
| ^^^^ help: consider spelling out the type instead: `Foo<'a>`
4+
LL | let x = {
5+
| - borrow later stored here
6+
LL | let bar = 22;
7+
LL | Foo::new(&bar).await
8+
| ^^^^ borrowed value does not live long enough
9+
LL |
10+
LL | };
11+
| - `bar` dropped here while still borrowed
612

713
error: aborting due to previous error
814

9-
For more information about this error, try `rustc --explain E0760`.
15+
For more information about this error, try `rustc --explain E0597`.

‎src/test/ui/async-await/issue-74072-lifetime-name-annotations.stderr

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
error[E0506]: cannot assign to `*x` because it is borrowed
22
--> $DIR/issue-74072-lifetime-name-annotations.rs:9:5
33
|
4-
LL | pub async fn async_fn(x: &mut i32) -> &i32 {
5-
| - let's call the lifetime of this reference `'1`
64
LL | let y = &*x;
75
| --- borrow of `*x` occurs here
86
LL | *x += 1;
97
| ^^^^^^^ assignment to borrowed `*x` occurs here
10-
LL | y
11-
| - returning this value requires that `*x` is borrowed for `'1`
128

139
error[E0506]: cannot assign to `*x` because it is borrowed
1410
--> $DIR/issue-74072-lifetime-name-annotations.rs:16:9

‎src/test/ui/async-await/issue-75785-confusing-named-region.stderr

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
error[E0506]: cannot assign to `*x` because it is borrowed
22
--> $DIR/issue-75785-confusing-named-region.rs:9:5
33
|
4-
LL | pub async fn async_fn(x: &mut i32) -> (&i32, &i32) {
5-
| - let's call the lifetime of this reference `'1`
64
LL | let y = &*x;
75
| --- borrow of `*x` occurs here
86
LL | *x += 1;
97
| ^^^^^^^ assignment to borrowed `*x` occurs here
10-
LL | (&32, y)
11-
| -------- returning this value requires that `*x` is borrowed for `'1`
128

139
error: aborting due to previous error
1410

‎src/test/ui/async-await/issues/issue-63388-1.stderr

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ error[E0623]: lifetime mismatch
22
--> $DIR/issue-63388-1.rs:14:9
33
|
44
LL | &'a self, foo: &dyn Foo
5-
| -------- this parameter and the return type are declared with different lifetimes...
6-
LL | ) -> &dyn Foo
7-
| --------
8-
LL | {
5+
| -------- -------- these two types are declared with different lifetimes...
6+
...
97
LL | foo
10-
| ^^^ ...but data from `foo` is returned here
8+
| ^^^ ...but data from `foo` flows into `self` here
119

1210
error: aborting due to previous error
1311

‎src/test/ui/async-await/issues/issue-78600.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
// check-pass
12
// edition:2018
23

34
struct S<'a>(&'a i32);
45

56
impl<'a> S<'a> {
67
async fn new(i: &'a i32) -> Result<Self, ()> {
7-
//~^ ERROR: `async fn`
88
Ok(S(&22))
99
}
1010
}

‎src/test/ui/async-await/issues/issue-78600.stderr

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ error[E0623]: lifetime mismatch
22
--> $DIR/ret-impl-trait-one.rs:10:65
33
|
44
LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b {
5-
| ------ ^^^^^^^^^^^^^^^^^^^
6-
| | |
7-
| | ...but data from `a` is returned here
8-
| this parameter and the return type are declared with different lifetimes...
5+
| ------ ------ ^^^^^^^^^^^^^^^^^^^ ...but data from `a` flows into `b` here
6+
| |
7+
| these two types are declared with different lifetimes...
98

109
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
1110
--> $DIR/ret-impl-trait-one.rs:16:65

‎src/test/ui/async-await/unused-lifetime.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
// Even wrong cases don't cause errors because async functions are desugared with all lifetimes
1111
// involved in the signature. So, we cannot predict what lifetimes are unused in async function.
1212
async fn async_wrong_without_args<'a>() {}
13+
//~^ ERROR lifetime parameter `'a` never used [unused_lifetimes]
1314

1415
async fn async_wrong_1_lifetime<'a>(_: &i32) {}
16+
//~^ ERROR lifetime parameter `'a` never used [unused_lifetimes]
1517

1618
async fn async_wrong_2_lifetimes<'a, 'b>(_: &'a i32, _: &i32) {}
19+
//~^ ERROR lifetime parameter `'b` never used [unused_lifetimes]
1720

1821
async fn async_right_1_lifetime<'a>(_: &'a i32) {}
1922

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: lifetime parameter `'a` never used
2-
--> $DIR/unused-lifetime.rs:31:23
2+
--> $DIR/unused-lifetime.rs:12:35
33
|
4-
LL | fn wrong_without_args<'a>() {}
5-
| -^^- help: elide the unused lifetime
4+
LL | async fn async_wrong_without_args<'a>() {}
5+
| -^^- help: elide the unused lifetime
66
|
77
note: the lint level is defined here
88
--> $DIR/unused-lifetime.rs:5:9
@@ -11,18 +11,40 @@ LL | #![deny(unused_lifetimes)]
1111
| ^^^^^^^^^^^^^^^^
1212

1313
error: lifetime parameter `'a` never used
14-
--> $DIR/unused-lifetime.rs:33:21
14+
--> $DIR/unused-lifetime.rs:15:33
15+
|
16+
LL | async fn async_wrong_1_lifetime<'a>(_: &i32) {}
17+
| ^^-----
18+
| |
19+
| help: elide the unused lifetime
20+
21+
error: lifetime parameter `'b` never used
22+
--> $DIR/unused-lifetime.rs:18:38
23+
|
24+
LL | async fn async_wrong_2_lifetimes<'a, 'b>(_: &'a i32, _: &i32) {}
25+
| ^^-----------------
26+
| |
27+
| help: elide the unused lifetime
28+
29+
error: lifetime parameter `'a` never used
30+
--> $DIR/unused-lifetime.rs:34:23
31+
|
32+
LL | fn wrong_without_args<'a>() {}
33+
| -^^- help: elide the unused lifetime
34+
35+
error: lifetime parameter `'a` never used
36+
--> $DIR/unused-lifetime.rs:36:21
1537
|
1638
LL | fn wrong_1_lifetime<'a>(_: &i32) {}
1739
| -^^- help: elide the unused lifetime
1840

1941
error: lifetime parameter `'b` never used
20-
--> $DIR/unused-lifetime.rs:35:26
42+
--> $DIR/unused-lifetime.rs:38:26
2143
|
2244
LL | fn wrong_2_lifetimes<'a, 'b>(_: &'a i32, _: &i32) {}
2345
| --^^
2446
| |
2547
| help: elide the unused lifetime
2648

27-
error: aborting due to 3 previous errors
49+
error: aborting due to 6 previous errors
2850

‎src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ error[E0623]: lifetime mismatch
22
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:8:52
33
|
44
LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f }
5-
| ---- ---- ^ ...but data from `f` is returned here
5+
| ---- ---- ^ ...but data from `f` flows into `self` here
66
| |
7-
| this parameter and the return type are declared with different lifetimes...
7+
| these two types are declared with different lifetimes...
88

99
error[E0623]: lifetime mismatch
1010
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:11:82
1111
|
1212
LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) }
13-
| ---- ----------------- ^ ...but data from `f` is returned here
13+
| ----- ---- ^ ...but data from `f` flows into `self` here
1414
| |
15-
| this parameter and the return type are declared with different lifetimes...
15+
| these two types are declared with different lifetimes...
1616

1717
error[E0623]: lifetime mismatch
1818
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:17:64
1919
|
2020
LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg }
21-
| ------ --- ^^^ ...but data from `arg` is returned here
21+
| ----- ------ ^^^ ...but data from `arg` flows into `self` here
2222
| |
23-
| this parameter and the return type are declared with different lifetimes...
23+
| these two types are declared with different lifetimes...
2424

2525
error: aborting due to 3 previous errors
2626

‎src/test/ui/self/elision/lt-ref-self-async.stderr

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,49 @@ error[E0623]: lifetime mismatch
22
--> $DIR/lt-ref-self-async.rs:13:9
33
|
44
LL | async fn ref_self(&self, f: &u32) -> &u32 {
5-
| ---- ----
6-
| |
7-
| this parameter and the return type are declared with different lifetimes...
5+
| ----- ---- these two types are declared with different lifetimes...
86
LL | f
9-
| ^ ...but data from `f` is returned here
7+
| ^ ...but data from `f` flows into `self` here
108

119
error[E0623]: lifetime mismatch
1210
--> $DIR/lt-ref-self-async.rs:19:9
1311
|
1412
LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 {
15-
| ---- ----
16-
| |
17-
| this parameter and the return type are declared with different lifetimes...
13+
| ----- ---- these two types are declared with different lifetimes...
1814
LL | f
19-
| ^ ...but data from `f` is returned here
15+
| ^ ...but data from `f` flows into `self` here
2016

2117
error[E0623]: lifetime mismatch
2218
--> $DIR/lt-ref-self-async.rs:23:9
2319
|
2420
LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
25-
| ---- ----
26-
| |
27-
| this parameter and the return type are declared with different lifetimes...
21+
| ----- ---- these two types are declared with different lifetimes...
2822
LL | f
29-
| ^ ...but data from `f` is returned here
23+
| ^ ...but data from `f` flows into `self` here
3024

3125
error[E0623]: lifetime mismatch
3226
--> $DIR/lt-ref-self-async.rs:27:9
3327
|
3428
LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
35-
| ---- ----
36-
| |
37-
| this parameter and the return type are declared with different lifetimes...
29+
| ----- ---- these two types are declared with different lifetimes...
3830
LL | f
39-
| ^ ...but data from `f` is returned here
31+
| ^ ...but data from `f` flows into `self` here
4032

4133
error[E0623]: lifetime mismatch
4234
--> $DIR/lt-ref-self-async.rs:31:9
4335
|
4436
LL | async fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
45-
| ---- ----
46-
| |
47-
| this parameter and the return type are declared with different lifetimes...
37+
| ----- ---- these two types are declared with different lifetimes...
4838
LL | f
49-
| ^ ...but data from `f` is returned here
39+
| ^ ...but data from `f` flows into `self` here
5040

5141
error[E0623]: lifetime mismatch
5242
--> $DIR/lt-ref-self-async.rs:35:9
5343
|
5444
LL | async fn box_pin_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
55-
| ---- ----
56-
| |
57-
| this parameter and the return type are declared with different lifetimes...
45+
| ----- ---- these two types are declared with different lifetimes...
5846
LL | f
59-
| ^ ...but data from `f` is returned here
47+
| ^ ...but data from `f` flows into `self` here
6048

6149
error: aborting due to 6 previous errors
6250

‎src/test/ui/self/elision/ref-mut-self-async.stderr

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,49 @@ error[E0623]: lifetime mismatch
22
--> $DIR/ref-mut-self-async.rs:13:9
33
|
44
LL | async fn ref_self(&mut self, f: &u32) -> &u32 {
5-
| ---- ----
6-
| |
7-
| this parameter and the return type are declared with different lifetimes...
5+
| --------- ---- these two types are declared with different lifetimes...
86
LL | f
9-
| ^ ...but data from `f` is returned here
7+
| ^ ...but data from `f` flows into `self` here
108

119
error[E0623]: lifetime mismatch
1210
--> $DIR/ref-mut-self-async.rs:19:9
1311
|
1412
LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 {
15-
| ---- ----
16-
| |
17-
| this parameter and the return type are declared with different lifetimes...
13+
| --------- ---- these two types are declared with different lifetimes...
1814
LL | f
19-
| ^ ...but data from `f` is returned here
15+
| ^ ...but data from `f` flows into `self` here
2016

2117
error[E0623]: lifetime mismatch
2218
--> $DIR/ref-mut-self-async.rs:23:9
2319
|
2420
LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 {
25-
| ---- ----
26-
| |
27-
| this parameter and the return type are declared with different lifetimes...
21+
| --------- ---- these two types are declared with different lifetimes...
2822
LL | f
29-
| ^ ...but data from `f` is returned here
23+
| ^ ...but data from `f` flows into `self` here
3024

3125
error[E0623]: lifetime mismatch
3226
--> $DIR/ref-mut-self-async.rs:27:9
3327
|
3428
LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 {
35-
| ---- ----
36-
| |
37-
| this parameter and the return type are declared with different lifetimes...
29+
| --------- ---- these two types are declared with different lifetimes...
3830
LL | f
39-
| ^ ...but data from `f` is returned here
31+
| ^ ...but data from `f` flows into `self` here
4032

4133
error[E0623]: lifetime mismatch
4234
--> $DIR/ref-mut-self-async.rs:31:9
4335
|
4436
LL | async fn box_box_ref_Self(self: Box<Box<&mut Self>>, f: &u32) -> &u32 {
45-
| ---- ----
46-
| |
47-
| this parameter and the return type are declared with different lifetimes...
37+
| --------- ---- these two types are declared with different lifetimes...
4838
LL | f
49-
| ^ ...but data from `f` is returned here
39+
| ^ ...but data from `f` flows into `self` here
5040

5141
error[E0623]: lifetime mismatch
5242
--> $DIR/ref-mut-self-async.rs:35:9
5343
|
5444
LL | async fn box_pin_ref_Self(self: Box<Pin<&mut Self>>, f: &u32) -> &u32 {
55-
| ---- ----
56-
| |
57-
| this parameter and the return type are declared with different lifetimes...
45+
| --------- ---- these two types are declared with different lifetimes...
5846
LL | f
59-
| ^ ...but data from `f` is returned here
47+
| ^ ...but data from `f` flows into `self` here
6048

6149
error: aborting due to 6 previous errors
6250

‎src/test/ui/self/elision/ref-mut-struct-async.stderr

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,41 @@ error[E0623]: lifetime mismatch
22
--> $DIR/ref-mut-struct-async.rs:13:9
33
|
44
LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 {
5-
| ---- ----
6-
| |
7-
| this parameter and the return type are declared with different lifetimes...
5+
| ----------- ---- these two types are declared with different lifetimes...
86
LL | f
9-
| ^ ...but data from `f` is returned here
7+
| ^ ...but data from `f` flows into `self` here
108

119
error[E0623]: lifetime mismatch
1210
--> $DIR/ref-mut-struct-async.rs:17:9
1311
|
1412
LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 {
15-
| ---- ----
16-
| |
17-
| this parameter and the return type are declared with different lifetimes...
13+
| ----------- ---- these two types are declared with different lifetimes...
1814
LL | f
19-
| ^ ...but data from `f` is returned here
15+
| ^ ...but data from `f` flows into `self` here
2016

2117
error[E0623]: lifetime mismatch
2218
--> $DIR/ref-mut-struct-async.rs:21:9
2319
|
2420
LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 {
25-
| ---- ----
26-
| |
27-
| this parameter and the return type are declared with different lifetimes...
21+
| ----------- ---- these two types are declared with different lifetimes...
2822
LL | f
29-
| ^ ...but data from `f` is returned here
23+
| ^ ...but data from `f` flows into `self` here
3024

3125
error[E0623]: lifetime mismatch
3226
--> $DIR/ref-mut-struct-async.rs:25:9
3327
|
3428
LL | async fn box_box_ref_Struct(self: Box<Box<&mut Struct>>, f: &u32) -> &u32 {
35-
| ---- ----
36-
| |
37-
| this parameter and the return type are declared with different lifetimes...
29+
| ----------- ---- these two types are declared with different lifetimes...
3830
LL | f
39-
| ^ ...but data from `f` is returned here
31+
| ^ ...but data from `f` flows into `self` here
4032

4133
error[E0623]: lifetime mismatch
4234
--> $DIR/ref-mut-struct-async.rs:29:9
4335
|
4436
LL | async fn box_pin_ref_Struct(self: Box<Pin<&mut Struct>>, f: &u32) -> &u32 {
45-
| ---- ----
46-
| |
47-
| this parameter and the return type are declared with different lifetimes...
37+
| ----------- ---- these two types are declared with different lifetimes...
4838
LL | f
49-
| ^ ...but data from `f` is returned here
39+
| ^ ...but data from `f` flows into `self` here
5040

5141
error: aborting due to 5 previous errors
5242

‎src/test/ui/self/elision/ref-self-async.stderr

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,71 +2,57 @@ error[E0623]: lifetime mismatch
22
--> $DIR/ref-self-async.rs:23:9
33
|
44
LL | async fn ref_self(&self, f: &u32) -> &u32 {
5-
| ---- ----
6-
| |
7-
| this parameter and the return type are declared with different lifetimes...
5+
| ----- ---- these two types are declared with different lifetimes...
86
LL | f
9-
| ^ ...but data from `f` is returned here
7+
| ^ ...but data from `f` flows into `self` here
108

119
error[E0623]: lifetime mismatch
1210
--> $DIR/ref-self-async.rs:29:9
1311
|
1412
LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 {
15-
| ---- ----
16-
| |
17-
| this parameter and the return type are declared with different lifetimes...
13+
| ----- ---- these two types are declared with different lifetimes...
1814
LL | f
19-
| ^ ...but data from `f` is returned here
15+
| ^ ...but data from `f` flows into `self` here
2016

2117
error[E0623]: lifetime mismatch
2218
--> $DIR/ref-self-async.rs:33:9
2319
|
2420
LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
25-
| ---- ----
26-
| |
27-
| this parameter and the return type are declared with different lifetimes...
21+
| ----- ---- these two types are declared with different lifetimes...
2822
LL | f
29-
| ^ ...but data from `f` is returned here
23+
| ^ ...but data from `f` flows into `self` here
3024

3125
error[E0623]: lifetime mismatch
3226
--> $DIR/ref-self-async.rs:37:9
3327
|
3428
LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
35-
| ---- ----
36-
| |
37-
| this parameter and the return type are declared with different lifetimes...
29+
| ----- ---- these two types are declared with different lifetimes...
3830
LL | f
39-
| ^ ...but data from `f` is returned here
31+
| ^ ...but data from `f` flows into `self` here
4032

4133
error[E0623]: lifetime mismatch
4234
--> $DIR/ref-self-async.rs:41:9
4335
|
4436
LL | async fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
45-
| ---- ----
46-
| |
47-
| this parameter and the return type are declared with different lifetimes...
37+
| ----- ---- these two types are declared with different lifetimes...
4838
LL | f
49-
| ^ ...but data from `f` is returned here
39+
| ^ ...but data from `f` flows into `self` here
5040

5141
error[E0623]: lifetime mismatch
5242
--> $DIR/ref-self-async.rs:45:9
5343
|
5444
LL | async fn box_pin_ref_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
55-
| ---- ----
56-
| |
57-
| this parameter and the return type are declared with different lifetimes...
45+
| ----- ---- these two types are declared with different lifetimes...
5846
LL | f
59-
| ^ ...but data from `f` is returned here
47+
| ^ ...but data from `f` flows into `self` here
6048

6149
error[E0623]: lifetime mismatch
6250
--> $DIR/ref-self-async.rs:49:9
6351
|
6452
LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 {
65-
| --- ---
66-
| |
67-
| this parameter and the return type are declared with different lifetimes...
53+
| ----- --- these two types are declared with different lifetimes...
6854
LL | f
69-
| ^ ...but data from `f` is returned here
55+
| ^ ...but data from `f` flows into `self` here
7056

7157
error: aborting due to 7 previous errors
7258

‎src/test/ui/self/elision/ref-struct-async.stderr

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,41 @@ error[E0623]: lifetime mismatch
22
--> $DIR/ref-struct-async.rs:13:9
33
|
44
LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
5-
| ---- ----
6-
| |
7-
| this parameter and the return type are declared with different lifetimes...
5+
| ------- ---- these two types are declared with different lifetimes...
86
LL | f
9-
| ^ ...but data from `f` is returned here
7+
| ^ ...but data from `f` flows into `self` here
108

119
error[E0623]: lifetime mismatch
1210
--> $DIR/ref-struct-async.rs:17:9
1311
|
1412
LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 {
15-
| ---- ----
16-
| |
17-
| this parameter and the return type are declared with different lifetimes...
13+
| ------- ---- these two types are declared with different lifetimes...
1814
LL | f
19-
| ^ ...but data from `f` is returned here
15+
| ^ ...but data from `f` flows into `self` here
2016

2117
error[E0623]: lifetime mismatch
2218
--> $DIR/ref-struct-async.rs:21:9
2319
|
2420
LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 {
25-
| ---- ----
26-
| |
27-
| this parameter and the return type are declared with different lifetimes...
21+
| ------- ---- these two types are declared with different lifetimes...
2822
LL | f
29-
| ^ ...but data from `f` is returned here
23+
| ^ ...but data from `f` flows into `self` here
3024

3125
error[E0623]: lifetime mismatch
3226
--> $DIR/ref-struct-async.rs:25:9
3327
|
3428
LL | async fn box_box_ref_Struct(self: Box<Box<&Struct>>, f: &u32) -> &u32 {
35-
| ---- ----
36-
| |
37-
| this parameter and the return type are declared with different lifetimes...
29+
| ------- ---- these two types are declared with different lifetimes...
3830
LL | f
39-
| ^ ...but data from `f` is returned here
31+
| ^ ...but data from `f` flows into `self` here
4032

4133
error[E0623]: lifetime mismatch
4234
--> $DIR/ref-struct-async.rs:29:9
4335
|
4436
LL | async fn box_pin_Struct(self: Box<Pin<&Struct>>, f: &u32) -> &u32 {
45-
| ---- ----
46-
| |
47-
| this parameter and the return type are declared with different lifetimes...
37+
| ------- ---- these two types are declared with different lifetimes...
4838
LL | f
49-
| ^ ...but data from `f` is returned here
39+
| ^ ...but data from `f` flows into `self` here
5040

5141
error: aborting due to 5 previous errors
5242

0 commit comments

Comments
 (0)
Please sign in to comment.