Skip to content

Commit 86d17b9

Browse files
committedFeb 17, 2022
Revert "Auto merge of #91403 - cjgillot:inherit-async, r=oli-obk"
This reverts commit 3cfa4de, reversing changes made to 5d8767c.
1 parent 30b3f35 commit 86d17b9

34 files changed

+281
-227
lines changed
 

‎compiler/rustc_ast_lowering/src/lib.rs

+50-19
Original file line numberDiff line numberDiff line change
@@ -1659,12 +1659,11 @@ 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:
1662+
// return type). This is done by introducing lifetime parameters for:
16631663
//
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.
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.
16681667
//
16691668
// So for example in this snippet:
16701669
//
@@ -1680,22 +1679,44 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
16801679
// we would create an opaque type like:
16811680
//
16821681
// ```
1683-
// type Foo<'a>::bar<'b, '0, '1>::Bar<'2> = impl Future<Output = &'2 u32>;
1682+
// type Bar<'a, 'b, '0, '1, '2> = impl Future<Output = &'2 u32>;
16841683
// ```
16851684
//
16861685
// and we would then desugar `bar` to the equivalent of:
16871686
//
16881687
// ```rust
16891688
// impl<'a> Foo<'a> {
1690-
// fn bar<'b, '0, '1>(&'0 self, x: &'b Vec<f64>, y: &'1 str) -> Bar<'_>
1689+
// fn bar<'b, '0, '1>(&'0 self, x: &'b Vec<f64>, y: &'1 str) -> Bar<'a, 'b, '0, '1, '_>
16911690
// }
16921691
// ```
16931692
//
16941693
// Note that the final parameter to `Bar` is `'_`, not `'2` --
16951694
// this is because the elided lifetimes from the return type
16961695
// should be figured out using the ordinary elision rules, and
16971696
// this desugaring achieves that.
1698-
let mut lifetime_params = Vec::new();
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+
16991720
self.with_hir_id_owner(opaque_ty_node_id, |this| {
17001721
// We have to be careful to get elision right here. The
17011722
// idea is that we create a lifetime parameter for each
@@ -1714,12 +1735,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17141735
debug!("lower_async_fn_ret_ty: future_bound={:#?}", future_bound);
17151736
debug!("lower_async_fn_ret_ty: lifetimes_to_define={:#?}", lifetimes_to_define);
17161737

1717-
// Output lifetime like `'_`:
1718-
lifetime_params = lifetimes_to_define;
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+
);
17191744
debug!("lower_async_fn_ret_ty: lifetime_params={:#?}", lifetime_params);
17201745

17211746
let generic_params =
1722-
this.arena.alloc_from_iter(lifetime_params.iter().map(|&(span, hir_name)| {
1747+
this.arena.alloc_from_iter(lifetime_params.iter().map(|&(span, hir_name, _)| {
17231748
this.lifetime_to_generic_param(span, hir_name, opaque_ty_def_id)
17241749
}));
17251750

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

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:
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:
17431769
//
17441770
// ```
1745-
// For<'a>::bar<'b, '0, '1>::Bar<'_>
1771+
// Bar<'a, 'b, '0, '1, '_>
17461772
// ```
17471773
//
1748-
// For the "input" lifetime parameters are inherited automatically.
1749-
// For the "output" lifetime parameters, we just want to generate `'_`.
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 `'_`.
17501781
let generic_args =
1751-
self.arena.alloc_from_iter(lifetime_params.into_iter().map(|(span, _)| {
1782+
self.arena.alloc_from_iter(lifetime_params.into_iter().map(|(span, _, name)| {
17521783
GenericArg::Lifetime(hir::Lifetime {
17531784
hir_id: self.next_id(),
17541785
span: self.lower_span(span),
1755-
name: hir::LifetimeName::Implicit(false),
1786+
name,
17561787
})
17571788
}));
17581789

‎compiler/rustc_borrowck/src/region_infer/mod.rs

-18
Original file line numberDiff line numberDiff line change
@@ -2156,24 +2156,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
21562156
}
21572157
}
21582158

2159-
// When in async fn, prefer errors that come from inside the closure.
2160-
if !categorized_path[i].from_closure {
2161-
let span = categorized_path.iter().find_map(|p| {
2162-
if p.from_closure
2163-
&& p.category == categorized_path[i].category
2164-
&& categorized_path[i].cause.span.contains(p.cause.span)
2165-
{
2166-
Some(p.cause.span)
2167-
} else {
2168-
None
2169-
}
2170-
});
2171-
2172-
if let Some(span) = span {
2173-
categorized_path[i].cause.span = span;
2174-
}
2175-
}
2176-
21772159
return categorized_path[i].clone();
21782160
}
21792161

‎compiler/rustc_error_codes/src/error_codes/E0760.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
`impl trait` return type cannot contain a projection
1+
`async fn`/`impl trait` return type cannot contain a projection
22
or `Self` that references lifetimes from a parent scope.
33

44
Erroneous code example:
@@ -7,7 +7,7 @@ Erroneous code example:
77
struct S<'a>(&'a i32);
88
99
impl<'a> S<'a> {
10-
fn new(i: &'a i32) -> impl Into<Self> {
10+
async fn new(i: &'a i32) -> Self {
1111
S(&22)
1212
}
1313
}
@@ -19,7 +19,7 @@ To fix this error we need to spell out `Self` to `S<'a>`:
1919
struct S<'a>(&'a i32);
2020
2121
impl<'a> S<'a> {
22-
fn new(i: &'a i32) -> impl Into<S<'a>> {
22+
async fn new(i: &'a i32) -> S<'a> {
2323
S(&22)
2424
}
2525
}

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

+2-2
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(..) => {
279+
hir::OpaqueTyOrigin::FnReturn(..) | hir::OpaqueTyOrigin::AsyncFn(..) => {
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::AsyncFn(..) | hir::OpaqueTyOrigin::TyAlias => 0,
294+
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

+8-26
Original file line numberDiff line numberDiff line change
@@ -729,16 +729,9 @@ 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(
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-
);
732+
self.visit_early_late(None, item.hir_id(), &sig.decl, generics, |this| {
733+
intravisit::walk_item(this, item);
734+
});
742735
self.missing_named_lifetime_spots.pop();
743736
}
744737

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

857850
fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem<'tcx>) {
858851
match item.kind {
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| {
852+
hir::ForeignItemKind::Fn(ref decl, _, ref generics) => {
853+
self.visit_early_late(None, item.hir_id(), decl, generics, |this| {
866854
intravisit::walk_foreign_item(this, item);
867-
},
868-
),
855+
})
856+
}
869857
hir::ForeignItemKind::Static(..) => {
870858
intravisit::walk_foreign_item(self, item);
871859
}
@@ -1142,7 +1130,6 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
11421130
trait_item.hir_id(),
11431131
&sig.decl,
11441132
&trait_item.generics,
1145-
sig.header.asyncness,
11461133
|this| intravisit::walk_trait_item(this, trait_item),
11471134
);
11481135
self.missing_named_lifetime_spots.pop();
@@ -1212,7 +1199,6 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
12121199
impl_item.hir_id(),
12131200
&sig.decl,
12141201
&impl_item.generics,
1215-
sig.header.asyncness,
12161202
|this| intravisit::walk_impl_item(this, impl_item),
12171203
);
12181204
self.missing_named_lifetime_spots.pop();
@@ -2173,15 +2159,11 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
21732159
hir_id: hir::HirId,
21742160
decl: &'tcx hir::FnDecl<'tcx>,
21752161
generics: &'tcx hir::Generics<'tcx>,
2176-
asyncness: hir::IsAsync,
21772162
walk: F,
21782163
) where
21792164
F: for<'b, 'c> FnOnce(&'b mut LifetimeContext<'c, 'tcx>),
21802165
{
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-
}
2166+
insert_late_bound_lifetimes(self.map, decl, generics);
21852167

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

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

+10-5
Original file line numberDiff line numberDiff line change
@@ -2409,11 +2409,16 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
24092409
let def_id = item_id.def_id.to_def_id();
24102410

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

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

+12-3
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,10 @@ pub(super) fn check_opaque_for_inheriting_lifetimes<'tcx>(
545545
}
546546
}
547547

548-
if let ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::FnReturn(..), .. }) =
549-
item.kind
548+
if let ItemKind::OpaqueTy(hir::OpaqueTy {
549+
origin: hir::OpaqueTyOrigin::AsyncFn(..) | hir::OpaqueTyOrigin::FnReturn(..),
550+
..
551+
}) = item.kind
550552
{
551553
let mut visitor = ProhibitOpaqueVisitor {
552554
opaque_identity_ty: tcx.mk_opaque(
@@ -568,13 +570,20 @@ pub(super) fn check_opaque_for_inheriting_lifetimes<'tcx>(
568570

569571
if let Some(ty) = prohibit_opaque.break_value() {
570572
visitor.visit_item(&item);
573+
let is_async = match item.kind {
574+
ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => {
575+
matches!(origin, hir::OpaqueTyOrigin::AsyncFn(..))
576+
}
577+
_ => unreachable!(),
578+
};
571579

572580
let mut err = struct_span_err!(
573581
tcx.sess,
574582
span,
575583
E0760,
576-
"`impl Trait` return type cannot contain a projection or `Self` that references lifetimes from \
584+
"`{}` return type cannot contain a projection or `Self` that references lifetimes from \
577585
a parent scope",
586+
if is_async { "async fn" } else { "impl Trait" },
578587
);
579588

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

‎compiler/rustc_typeck/src/collect.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2157,7 +2157,8 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
21572157
generics
21582158
}
21592159
ItemKind::OpaqueTy(OpaqueTy {
2160-
origin: hir::OpaqueTyOrigin::FnReturn(..), ..
2160+
origin: hir::OpaqueTyOrigin::AsyncFn(..) | hir::OpaqueTyOrigin::FnReturn(..),
2161+
..
21612162
}) => {
21622163
// return-position impl trait
21632164
//
@@ -2177,7 +2178,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
21772178
}
21782179
ItemKind::OpaqueTy(OpaqueTy {
21792180
ref generics,
2180-
origin: hir::OpaqueTyOrigin::AsyncFn(..) | hir::OpaqueTyOrigin::TyAlias,
2181+
origin: hir::OpaqueTyOrigin::TyAlias,
21812182
..
21822183
}) => {
21832184
// type-alias impl trait

‎src/librustdoc/clean/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -585,12 +585,7 @@ fn clean_ty_generics(
585585
.params
586586
.iter()
587587
.filter_map(|param| match param.kind {
588-
ty::GenericParamDefKind::Lifetime => {
589-
if param.name == kw::UnderscoreLifetime {
590-
return None;
591-
}
592-
Some(param.clean(cx))
593-
}
588+
ty::GenericParamDefKind::Lifetime => Some(param.clean(cx)),
594589
ty::GenericParamDefKind::Type { synthetic, .. } => {
595590
if param.name == kw::SelfUpper {
596591
assert_eq!(param.index, 0);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ 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
1112
Foo {
1213
bar: &22
1314
}
@@ -18,7 +19,6 @@ async fn foo() {
1819
let x = {
1920
let bar = 22;
2021
Foo::new(&bar).await
21-
//~^ ERROR `bar` does not live long enough [E0597]
2222
};
2323
drop(x);
2424
}
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
error[E0597]: `bar` does not live long enough
2-
--> $DIR/issue-61949-self-return-type.rs:20:18
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
33
|
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
4+
LL | pub async fn new(_bar: &'a i32) -> Self {
5+
| ^^^^ help: consider spelling out the type instead: `Foo<'a>`
126

137
error: aborting due to previous error
148

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

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

+4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
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`
46
LL | let y = &*x;
57
| --- borrow of `*x` occurs here
68
LL | *x += 1;
79
| ^^^^^^^ assignment to borrowed `*x` occurs here
10+
LL | y
11+
| - returning this value requires that `*x` is borrowed for `'1`
812

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

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

+4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
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`
46
LL | let y = &*x;
57
| --- borrow of `*x` occurs here
68
LL | *x += 1;
79
| ^^^^^^^ assignment to borrowed `*x` occurs here
10+
LL | (&32, y)
11+
| -------- returning this value requires that `*x` is borrowed for `'1`
812

913
error: aborting due to previous error
1014

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

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

1012
error: aborting due to previous error
1113

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// check-pass
21
// edition:2018
32

43
struct S<'a>(&'a i32);
54

65
impl<'a> S<'a> {
76
async fn new(i: &'a i32) -> Result<Self, ()> {
7+
//~^ ERROR: `async fn`
88
Ok(S(&22))
99
}
1010
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0760]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
2+
--> $DIR/issue-78600.rs:6:33
3+
|
4+
LL | async fn new(i: &'a i32) -> Result<Self, ()> {
5+
| ^^^^^^^----^^^^^
6+
| |
7+
| help: consider spelling out the type instead: `S<'a>`
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0760`.

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

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
error: lifetime may not live long enough
2-
--> $DIR/ret-impl-trait-one.rs:12:5
2+
--> $DIR/ret-impl-trait-one.rs:10:85
33
|
4-
LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b {
5-
| -- -- lifetime `'b` defined here
6-
| |
7-
| lifetime `'a` defined here
8-
LL |
9-
LL | (a, b)
10-
| ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
4+
LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b {
5+
| ________________________________--__--_______________________________________________^
6+
| | | |
7+
| | | lifetime `'b` defined here
8+
| | lifetime `'a` defined here
9+
LL | |
10+
LL | | (a, b)
11+
LL | | }
12+
| |_^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
1113
|
1214
= help: consider adding the following bound: `'a: 'b`
1315

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ 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-
| ------ ------ ^^^^^^^^^^^^^^^^^^^ ...but data from `a` flows into `b` here
6-
| |
7-
| these two types are declared with different lifetimes...
5+
| ------ ^^^^^^^^^^^^^^^^^^^
6+
| | |
7+
| | ...but data from `a` is returned here
8+
| this parameter and the return type are declared with different lifetimes...
89

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

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

-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@
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]
1413

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

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

2118
async fn async_right_1_lifetime<'a>(_: &'a i32) {}
2219

Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: lifetime parameter `'a` never used
2-
--> $DIR/unused-lifetime.rs:12:35
2+
--> $DIR/unused-lifetime.rs:31:23
33
|
4-
LL | async fn async_wrong_without_args<'a>() {}
5-
| -^^- help: elide the unused lifetime
4+
LL | fn 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,40 +11,18 @@ LL | #![deny(unused_lifetimes)]
1111
| ^^^^^^^^^^^^^^^^
1212

1313
error: lifetime parameter `'a` never used
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
14+
--> $DIR/unused-lifetime.rs:33:21
3715
|
3816
LL | fn wrong_1_lifetime<'a>(_: &i32) {}
3917
| -^^- help: elide the unused lifetime
4018

4119
error: lifetime parameter `'b` never used
42-
--> $DIR/unused-lifetime.rs:38:26
20+
--> $DIR/unused-lifetime.rs:35:26
4321
|
4422
LL | fn wrong_2_lifetimes<'a, 'b>(_: &'a i32, _: &i32) {}
4523
| --^^
4624
| |
4725
| help: elide the unused lifetime
4826

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

‎src/test/ui/dropck/drop-with-active-borrows-2.stderr

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
error[E0515]: cannot return value referencing local variable `raw_lines`
2-
--> $DIR/drop-with-active-borrows-2.rs:3:30
2+
--> $DIR/drop-with-active-borrows-2.rs:3:5
33
|
44
LL | raw_lines.iter().map(|l| l.trim()).collect()
5-
| ---------------- ^^^^^^^^ returns a value referencing data owned by the current function
5+
| ----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
| |
7+
| returns a value referencing data owned by the current function
78
| `raw_lines` is borrowed here
89

910
error: aborting due to previous error

‎src/test/ui/issues/issue-13497-2.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
fn read_lines_borrowed<'a>() -> Vec<&'a str> {
22
let rawLines: Vec<String> = vec!["foo ".to_string(), " bar".to_string()];
3-
rawLines.iter().map(|l| l.trim()).collect()
4-
//~^ ERROR cannot return value referencing local variable `rawLines`
3+
rawLines //~ ERROR cannot return value referencing local variable `rawLines`
4+
.iter().map(|l| l.trim()).collect()
55
}
66

77
fn main() {}

‎src/test/ui/issues/issue-13497-2.stderr

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
error[E0515]: cannot return value referencing local variable `rawLines`
2-
--> $DIR/issue-13497-2.rs:3:29
2+
--> $DIR/issue-13497-2.rs:3:5
33
|
4-
LL | rawLines.iter().map(|l| l.trim()).collect()
5-
| --------------- ^^^^^^^^ returns a value referencing data owned by the current function
6-
| |
7-
| `rawLines` is borrowed here
4+
LL | rawLines
5+
| _____^
6+
| |_____|
7+
| ||
8+
LL | || .iter().map(|l| l.trim()).collect()
9+
| ||_______________-___________________________^ returns a value referencing data owned by the current function
10+
| |________________|
11+
| `rawLines` is borrowed here
812

913
error: aborting due to previous error
1014

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ error: lifetime may not live long enough
2020
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:17:64
2121
|
2222
LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg }
23-
| -- ---- has type `Pin<&'1 Foo>` ^^^ associated function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a`
24-
| |
23+
| -- - ^^^ associated function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a`
24+
| | |
25+
| | let's call the lifetime of this reference `'1`
2526
| lifetime `'a` defined here
2627

2728
error: aborting due to 3 previous errors

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

+6-6
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` flows into `self` here
5+
| ---- ---- ^ ...but data from `f` is returned here
66
| |
7-
| these two types are declared with different lifetimes...
7+
| this parameter and the return type 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` flows into `self` here
13+
| ---- ----------------- ^ ...but data from `f` is returned here
1414
| |
15-
| these two types are declared with different lifetimes...
15+
| this parameter and the return type 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` flows into `self` here
21+
| ------ --- ^^^ ...but data from `arg` is returned here
2222
| |
23-
| these two types are declared with different lifetimes...
23+
| this parameter and the return type 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

+24-12
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,61 @@ 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-
| ----- ---- these two types are declared with different lifetimes...
5+
| ---- ----
6+
| |
7+
| this parameter and the return type are declared with different lifetimes...
68
LL | f
7-
| ^ ...but data from `f` flows into `self` here
9+
| ^ ...but data from `f` is returned here
810

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

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

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

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

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

4961
error: aborting due to 6 previous errors
5062

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

+24-12
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,61 @@ 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-
| --------- ---- these two types are declared with different lifetimes...
5+
| ---- ----
6+
| |
7+
| this parameter and the return type are declared with different lifetimes...
68
LL | f
7-
| ^ ...but data from `f` flows into `self` here
9+
| ^ ...but data from `f` is returned here
810

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

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

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

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

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

4961
error: aborting due to 6 previous errors
5062

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

+20-10
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,51 @@ 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-
| ----------- ---- these two types are declared with different lifetimes...
5+
| ---- ----
6+
| |
7+
| this parameter and the return type are declared with different lifetimes...
68
LL | f
7-
| ^ ...but data from `f` flows into `self` here
9+
| ^ ...but data from `f` is returned here
810

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

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

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

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

4151
error: aborting due to 5 previous errors
4252

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

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

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

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

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

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

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

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

5771
error: aborting due to 7 previous errors
5872

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

+20-10
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,51 @@ 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-
| ------- ---- these two types are declared with different lifetimes...
5+
| ---- ----
6+
| |
7+
| this parameter and the return type are declared with different lifetimes...
68
LL | f
7-
| ^ ...but data from `f` flows into `self` here
9+
| ^ ...but data from `f` is returned here
810

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

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

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

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

4151
error: aborting due to 5 previous errors
4252

‎src/tools/clippy/tests/ui/manual_async_fn.fixed

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ fn elided_not_bound(_: &i32) -> impl Future<Output = i32> {
8080
async { 42 }
8181
}
8282

83-
#[allow(clippy::needless_lifetimes)]
8483
async fn explicit<'a, 'b>(_: &'a i32, _: &'b i32) -> i32 { 42 }
8584

8685
// should be ignored

‎src/tools/clippy/tests/ui/manual_async_fn.rs

-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ fn elided_not_bound(_: &i32) -> impl Future<Output = i32> {
9898
async { 42 }
9999
}
100100

101-
#[allow(clippy::needless_lifetimes)]
102101
fn explicit<'a, 'b>(_: &'a i32, _: &'b i32) -> impl Future<Output = i32> + 'a + 'b {
103102
async { 42 }
104103
}

‎src/tools/clippy/tests/ui/manual_async_fn.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ LL | fn elided(_: &i32) -> impl Future<Output = i32> + '_ { 42 }
140140
| ~~~~~~
141141

142142
error: this function can be simplified using the `async fn` syntax
143-
--> $DIR/manual_async_fn.rs:102:1
143+
--> $DIR/manual_async_fn.rs:101:1
144144
|
145145
LL | fn explicit<'a, 'b>(_: &'a i32, _: &'b i32) -> impl Future<Output = i32> + 'a + 'b {
146146
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

‎src/tools/clippy/tests/ui/needless_lifetimes.stderr

+1-7
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ error: explicit lifetimes given in parameter types where they could be elided (o
1818
LL | fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 {
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2020

21-
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
22-
--> $DIR/needless_lifetimes.rs:37:1
23-
|
24-
LL | async fn func<'a>(args: &[&'a str]) -> Option<&'a str> {
25-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26-
2721
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
2822
--> $DIR/needless_lifetimes.rs:56:1
2923
|
@@ -198,5 +192,5 @@ error: explicit lifetimes given in parameter types where they could be elided (o
198192
LL | fn lifetime_elsewhere_provided<'a>(self: Box<Self>, here: &'a ()) -> &'a () {
199193
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
200194

201-
error: aborting due to 33 previous errors
195+
error: aborting due to 32 previous errors
202196

0 commit comments

Comments
 (0)
Please sign in to comment.