From 03e7b9628199f5c82d083cd02116c4424a31f47f Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 12 Aug 2019 17:15:33 -0400 Subject: [PATCH] revamp how we handle elision in async fn We now always make fresh lifetimne parameters for all elided lifetimes, whether they are in the inputs or outputs. But then we generate `'_` in the case of elided lifetimes from the outputs. Example: ```rust async fn foo<'a>(x: &'a u32) -> &u32 { .. } ``` becomes ```rust type Foo<'a, 'b> = impl Future; fn foo<'a>(x: &'a u32) -> Foo<'a, '_> ``` --- src/librustc/hir/lowering.rs | 181 +++++----------- .../ui/async-await/issues/issue-63388-1.rs | 20 ++ .../async-await/issues/issue-63388-1.stderr | 12 ++ .../ui/async-await/issues/issue-63388-2.rs | 20 ++ .../async-await/issues/issue-63388-2.stderr | 29 +++ .../ui/async-await/issues/issue-63388-3.rs | 19 ++ .../ui/async-await/issues/issue-63388-4.rs | 12 ++ src/test/ui/self/elision/README.md | 16 +- src/test/ui/self/elision/lt-ref-self-async.rs | 24 +-- .../ui/self/elision/lt-ref-self-async.stderr | 179 ++++----------- .../multiple-ref-self-async.nll.stderr | 43 ---- .../self/elision/multiple-ref-self-async.rs | 11 +- .../elision/multiple-ref-self-async.stderr | 133 ------------ .../self/elision/ref-alias-async.nll.stderr | 43 ---- src/test/ui/self/elision/ref-alias-async.rs | 11 +- .../ui/self/elision/ref-alias-async.stderr | 133 ------------ .../self/elision/ref-assoc-async.nll.stderr | 43 ---- src/test/ui/self/elision/ref-assoc-async.rs | 11 +- .../ui/self/elision/ref-assoc-async.stderr | 133 ------------ .../elision/ref-mut-alias-async.nll.stderr | 43 ---- .../ui/self/elision/ref-mut-alias-async.rs | 12 +- .../self/elision/ref-mut-alias-async.stderr | 133 ------------ .../ui/self/elision/ref-mut-self-async.rs | 24 +-- .../ui/self/elision/ref-mut-self-async.stderr | 175 ++++----------- .../ui/self/elision/ref-mut-struct-async.rs | 20 +- .../self/elision/ref-mut-struct-async.stderr | 146 +++---------- src/test/ui/self/elision/ref-self-async.rs | 28 +-- .../ui/self/elision/ref-self-async.stderr | 204 ++++-------------- src/test/ui/self/elision/ref-struct-async.rs | 20 +- .../ui/self/elision/ref-struct-async.stderr | 146 +++---------- 30 files changed, 385 insertions(+), 1639 deletions(-) create mode 100644 src/test/ui/async-await/issues/issue-63388-1.rs create mode 100644 src/test/ui/async-await/issues/issue-63388-1.stderr create mode 100644 src/test/ui/async-await/issues/issue-63388-2.rs create mode 100644 src/test/ui/async-await/issues/issue-63388-2.stderr create mode 100644 src/test/ui/async-await/issues/issue-63388-3.rs create mode 100644 src/test/ui/async-await/issues/issue-63388-4.rs delete mode 100644 src/test/ui/self/elision/multiple-ref-self-async.nll.stderr delete mode 100644 src/test/ui/self/elision/multiple-ref-self-async.stderr delete mode 100644 src/test/ui/self/elision/ref-alias-async.nll.stderr delete mode 100644 src/test/ui/self/elision/ref-alias-async.stderr delete mode 100644 src/test/ui/self/elision/ref-assoc-async.nll.stderr delete mode 100644 src/test/ui/self/elision/ref-assoc-async.stderr delete mode 100644 src/test/ui/self/elision/ref-mut-alias-async.nll.stderr delete mode 100644 src/test/ui/self/elision/ref-mut-alias-async.stderr diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 493083c680a..8e7f96ca236 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -341,49 +341,6 @@ enum AnonymousLifetimeMode { /// Pass responsibility to `resolve_lifetime` code for all cases. PassThrough, - - /// Used in the return types of `async fn` where there exists - /// exactly one argument-position elided lifetime. - /// - /// In `async fn`, we lower the arguments types using the `CreateParameter` - /// mode, meaning that non-`dyn` elided lifetimes are assigned a fresh name. - /// If any corresponding elided lifetimes appear in the output, we need to - /// replace them with references to the fresh name assigned to the corresponding - /// elided lifetime in the arguments. - /// - /// For **Modern cases**, replace the anonymous parameter with a - /// reference to a specific freshly-named lifetime that was - /// introduced in argument - /// - /// For **Dyn Bound** cases, pass responsibility to - /// `resole_lifetime` code. - Replace(LtReplacement), -} - -/// The type of elided lifetime replacement to perform on `async fn` return types. -#[derive(Copy, Clone)] -enum LtReplacement { - /// Fresh name introduced by the single non-dyn elided lifetime - /// in the arguments of the async fn. - Some(ParamName), - - /// There is no single non-dyn elided lifetime because no lifetimes - /// appeared in the arguments. - NoLifetimes, - - /// There is no single non-dyn elided lifetime because multiple - /// lifetimes appeared in the arguments. - MultipleLifetimes, -} - -/// Calculates the `LtReplacement` to use for elided lifetimes in the return -/// type based on the fresh elided lifetimes introduced in argument position. -fn get_elided_lt_replacement(arg_position_lifetimes: &[(Span, ParamName)]) -> LtReplacement { - match arg_position_lifetimes { - [] => LtReplacement::NoLifetimes, - [(_span, param)] => LtReplacement::Some(*param), - _ => LtReplacement::MultipleLifetimes, - } } struct ImplTraitTypeIdVisitor<'a> { ids: &'a mut SmallVec<[NodeId; 1]> } @@ -2318,8 +2275,7 @@ impl<'a> LoweringContext<'a> { err.emit(); } AnonymousLifetimeMode::PassThrough | - AnonymousLifetimeMode::ReportError | - AnonymousLifetimeMode::Replace(_) => { + AnonymousLifetimeMode::ReportError => { self.sess.buffer_lint_with_diagnostic( ELIDED_LIFETIMES_IN_PATHS, CRATE_NODE_ID, @@ -2515,7 +2471,6 @@ impl<'a> LoweringContext<'a> { // Remember how many lifetimes were already around so that we can // only look at the lifetime parameters introduced by the arguments. - let lifetime_count_before_args = self.lifetimes_to_define.len(); let inputs = self.with_anonymous_lifetime_mode(lt_mode, |this| { decl.inputs .iter() @@ -2530,16 +2485,10 @@ impl<'a> LoweringContext<'a> { }); let output = if let Some(ret_id) = make_ret_async { - // Calculate the `LtReplacement` to use for any return-position elided - // lifetimes based on the elided lifetime parameters introduced in the args. - let lt_replacement = get_elided_lt_replacement( - &self.lifetimes_to_define[lifetime_count_before_args..] - ); self.lower_async_fn_ret_ty( &decl.output, in_band_ty_params.expect("`make_ret_async` but no `fn_def_id`").0, ret_id, - lt_replacement, ) } else { match decl.output { @@ -2604,7 +2553,6 @@ impl<'a> LoweringContext<'a> { output: &FunctionRetTy, fn_def_id: DefId, opaque_ty_node_id: NodeId, - elided_lt_replacement: LtReplacement, ) -> hir::FunctionRetTy { let span = output.span(); @@ -2622,9 +2570,18 @@ impl<'a> LoweringContext<'a> { self.allocate_hir_id_counter(opaque_ty_node_id); + let input_lifetimes_count = self.in_scope_lifetimes.len() + self.lifetimes_to_define.len(); let (opaque_ty_id, lifetime_params) = self.with_hir_id_owner(opaque_ty_node_id, |this| { + // We have to be careful to get elision right here. The + // idea is that we create a lifetime parameter for each + // lifetime in the return type. So, given a return type + // like `async fn foo(..) -> &[&u32]`, we lower to `impl + // Future`. + // + // Then, we will create `fn foo(..) -> Foo<'_, '_>`, and + // hence the elision takes place at the fn site. let future_bound = this.with_anonymous_lifetime_mode( - AnonymousLifetimeMode::Replace(elided_lt_replacement), + AnonymousLifetimeMode::CreateParameter, |this| this.lower_async_fn_output_type_to_future_bound( output, fn_def_id, @@ -2678,19 +2635,53 @@ impl<'a> LoweringContext<'a> { (opaque_ty_id, lifetime_params) }); - let generic_args = - lifetime_params - .iter().cloned() - .map(|(span, hir_name)| { - GenericArg::Lifetime(hir::Lifetime { - hir_id: self.next_id(), - span, - name: hir::LifetimeName::Param(hir_name), - }) + // Create the generic lifetime arguments that we will supply + // to the opaque return type. Consider: + // + // ```rust + // async fn foo(x: &u32, ) -> &[&u32] { .. } + // ``` + // + // Here, we would create something like: + // + // ```rust + // type Foo<'a, 'b, 'c> = impl Future; + // fn foo<'a>(x: &'a u32) -> Foo<'a, '_, '_> + // ``` + // + // Note that for the lifetimes which came from the input + // (`'a`, here), we supply them as arguments to the return + // type `Foo`. But for those lifetime parameters (`'b`, `'c`) + // that we created from the return type, we want to use `'_` + // in the return type, so as to trigger elision. + let mut generic_args: Vec<_> = + lifetime_params[..input_lifetimes_count] + .iter() + .map(|&(span, hir_name)| { + GenericArg::Lifetime(hir::Lifetime { + hir_id: self.next_id(), + span, + name: hir::LifetimeName::Param(hir_name), }) - .collect(); + }) + .collect(); + generic_args.extend( + lifetime_params[input_lifetimes_count..] + .iter() + .map(|&(span, _)| { + GenericArg::Lifetime(hir::Lifetime { + hir_id: self.next_id(), + span, + name: hir::LifetimeName::Implicit, + }) + }) + ); - let opaque_ty_ref = hir::TyKind::Def(hir::ItemId { id: opaque_ty_id }, generic_args); + // Create the `Foo<...>` refernece itself. Note that the `type + // Foo = impl Trait` is, internally, created as a child of the + // async fn, so the *type parameters* are inherited. It's + // only the lifetime parameters that we must supply. + let opaque_ty_ref = hir::TyKind::Def(hir::ItemId { id: opaque_ty_id }, generic_args.into()); hir::FunctionRetTy::Return(P(hir::Ty { node: opaque_ty_ref, @@ -2786,11 +2777,6 @@ impl<'a> LoweringContext<'a> { } AnonymousLifetimeMode::ReportError => self.new_error_lifetime(Some(l.id), span), - - AnonymousLifetimeMode::Replace(replacement) => { - let hir_id = self.lower_node_id(l.id); - self.replace_elided_lifetime(hir_id, span, replacement) - } }, ident => { self.maybe_collect_in_band_lifetime(ident); @@ -2813,39 +2799,6 @@ impl<'a> LoweringContext<'a> { } } - /// Replace a return-position elided lifetime with the elided lifetime - /// from the arguments. - fn replace_elided_lifetime( - &mut self, - hir_id: hir::HirId, - span: Span, - replacement: LtReplacement, - ) -> hir::Lifetime { - let multiple_or_none = match replacement { - LtReplacement::Some(name) => { - return hir::Lifetime { - hir_id, - span, - name: hir::LifetimeName::Param(name), - }; - } - LtReplacement::MultipleLifetimes => "multiple", - LtReplacement::NoLifetimes => "none", - }; - - let mut err = crate::middle::resolve_lifetime::report_missing_lifetime_specifiers( - self.sess, - span, - 1, - ); - err.note(&format!( - "return-position elided lifetimes require exactly one \ - input-position elided lifetime, found {}.", multiple_or_none)); - err.emit(); - - hir::Lifetime { hir_id, span, name: hir::LifetimeName::Error } - } - fn lower_generic_params( &mut self, params: &[GenericParam], @@ -5791,10 +5744,6 @@ impl<'a> LoweringContext<'a> { AnonymousLifetimeMode::ReportError => self.new_error_lifetime(None, span), AnonymousLifetimeMode::PassThrough => self.new_implicit_lifetime(span), - - AnonymousLifetimeMode::Replace(replacement) => { - self.new_replacement_lifetime(replacement, span) - } } } @@ -5848,10 +5797,6 @@ impl<'a> LoweringContext<'a> { // This is the normal case. AnonymousLifetimeMode::PassThrough => self.new_implicit_lifetime(span), - AnonymousLifetimeMode::Replace(replacement) => { - self.new_replacement_lifetime(replacement, span) - } - AnonymousLifetimeMode::ReportError => self.new_error_lifetime(None, span), } } @@ -5883,25 +5828,11 @@ impl<'a> LoweringContext<'a> { // This is the normal case. AnonymousLifetimeMode::PassThrough => {} - - // We don't need to do any replacement here as this lifetime - // doesn't refer to an elided lifetime elsewhere in the function - // signature. - AnonymousLifetimeMode::Replace(_) => {} } self.new_implicit_lifetime(span) } - fn new_replacement_lifetime( - &mut self, - replacement: LtReplacement, - span: Span, - ) -> hir::Lifetime { - let hir_id = self.next_id(); - self.replace_elided_lifetime(hir_id, span, replacement) - } - fn new_implicit_lifetime(&mut self, span: Span) -> hir::Lifetime { hir::Lifetime { hir_id: self.next_id(), diff --git a/src/test/ui/async-await/issues/issue-63388-1.rs b/src/test/ui/async-await/issues/issue-63388-1.rs new file mode 100644 index 00000000000..80003b0d701 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-63388-1.rs @@ -0,0 +1,20 @@ +// edition:2018 + +#![feature(async_await)] + +struct Xyz { + a: u64, +} + +trait Foo {} + +impl Xyz { + async fn do_sth<'a>( + &'a self, foo: &dyn Foo + ) -> &dyn Foo //~ ERROR lifetime mismatch + { + foo + } +} + +fn main() {} diff --git a/src/test/ui/async-await/issues/issue-63388-1.stderr b/src/test/ui/async-await/issues/issue-63388-1.stderr new file mode 100644 index 00000000000..5302adce5a0 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-63388-1.stderr @@ -0,0 +1,12 @@ +error[E0623]: lifetime mismatch + --> $DIR/issue-63388-1.rs:14:10 + | +LL | &'a self, foo: &dyn Foo + | -------- this parameter and the return type are declared with different lifetimes... +LL | ) -> &dyn Foo + | ^^^^^^^^ + | | + | ...but data from `foo` is returned here + +error: aborting due to previous error + diff --git a/src/test/ui/async-await/issues/issue-63388-2.rs b/src/test/ui/async-await/issues/issue-63388-2.rs new file mode 100644 index 00000000000..ca9bbef0d50 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-63388-2.rs @@ -0,0 +1,20 @@ +// edition:2018 + +#![feature(async_await)] + +struct Xyz { + a: u64, +} + +trait Foo {} + +impl Xyz { + async fn do_sth<'a>( + foo: &dyn Foo, bar: &'a dyn Foo //~ ERROR cannot infer + ) -> &dyn Foo //~ ERROR missing lifetime specifier + { + foo + } +} + +fn main() {} diff --git a/src/test/ui/async-await/issues/issue-63388-2.stderr b/src/test/ui/async-await/issues/issue-63388-2.stderr new file mode 100644 index 00000000000..1810138dc80 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-63388-2.stderr @@ -0,0 +1,29 @@ +error[E0106]: missing lifetime specifier + --> $DIR/issue-63388-2.rs:14:10 + | +LL | ) -> &dyn Foo + | ^ help: consider using the named lifetime: `&'a` + | + = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `foo` or `bar` + +error: cannot infer an appropriate lifetime + --> $DIR/issue-63388-2.rs:13:9 + | +LL | foo: &dyn Foo, bar: &'a dyn Foo + | ^^^ ...but this borrow... +LL | ) -> &dyn Foo + | -------- this return type evaluates to the `'static` lifetime... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 13:14 + --> $DIR/issue-63388-2.rs:13:14 + | +LL | foo: &dyn Foo, bar: &'a dyn Foo + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 13:14 + | +LL | ) -> &dyn Foo + '_ + | ^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/async-await/issues/issue-63388-3.rs b/src/test/ui/async-await/issues/issue-63388-3.rs new file mode 100644 index 00000000000..05f23f95965 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-63388-3.rs @@ -0,0 +1,19 @@ +// edition:2018 +// check-pass + +#![feature(async_await)] + +struct Xyz { + a: u64, +} + +trait Foo {} + +impl Xyz { + async fn do_sth( + &self, foo: &dyn Foo + ) { + } +} + +fn main() {} diff --git a/src/test/ui/async-await/issues/issue-63388-4.rs b/src/test/ui/async-await/issues/issue-63388-4.rs new file mode 100644 index 00000000000..0939242d7fc --- /dev/null +++ b/src/test/ui/async-await/issues/issue-63388-4.rs @@ -0,0 +1,12 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +struct A; + +impl A { + async fn foo(&self, f: &u32) -> &A { self } +} + +fn main() { } diff --git a/src/test/ui/self/elision/README.md b/src/test/ui/self/elision/README.md index c4f06433ba7..2db8a23be6e 100644 --- a/src/test/ui/self/elision/README.md +++ b/src/test/ui/self/elision/README.md @@ -61,15 +61,15 @@ Legends: | `struct-async.rs`| ✓ | ✓ | N/A | | `alias-async.rs`| ✓ | ✓ | N/A | | `assoc-async.rs`| ✓ | ✓ | N/A | -| `ref-self-async.rs` | X | X | α ⟶ β + γ | -| `ref-mut-self-async.rs` | X | X | α ⟶ β + γ | -| `ref-struct-async.rs` | X | X | α ⟶ β + γ | -| `ref-mut-struct-async.rs` | X | X | α ⟶ β + γ | -| `ref-alias-async.rs` | X | X | ✓ ⟶ β + γ | -| `ref-assoc-async.rs` | X | X | ✓ ⟶ β + γ | -| `ref-mut-alias-async.rs` | X | X | ✓ ⟶ β + γ | +| `ref-self-async.rs` | ✓ | ✓ | N/A | +| `ref-mut-self-async.rs` | ✓ | ✓ | N/A | +| `ref-struct-async.rs` | ✓ | ✓ | N/A | +| `ref-mut-struct-async.rs` | ✓ | ✓ | N/A | +| `ref-alias-async.rs` | ✓ | ✓ | N/A | +| `ref-assoc-async.rs` | ✓ | ✓ | N/A | +| `ref-mut-alias-async.rs` | ✓ | ✓ | N/A | | `lt-self-async.rs` | ✓ | ✓ | N/A | `lt-struct-async.rs` | ✓ | ✓ | N/A | `lt-alias-async.rs` | ✓ | ✓ | N/A | `lt-assoc-async.rs` | ✓ | ✓ | N/A -| `lt-ref-self-async.rs` | X | X | α ⟶ β + γ +| `lt-ref-self-async.rs` | ✓ | ✓ | N/A | diff --git a/src/test/ui/self/elision/lt-ref-self-async.rs b/src/test/ui/self/elision/lt-ref-self-async.rs index 84b91ba08b7..79a4771978a 100644 --- a/src/test/ui/self/elision/lt-ref-self-async.rs +++ b/src/test/ui/self/elision/lt-ref-self-async.rs @@ -13,41 +13,29 @@ impl<'a> Struct<'a> { // Test using `&self` sugar: async fn ref_self(&self, f: &u32) -> &u32 { - //~^ ERROR cannot infer an appropriate lifetime - //~| ERROR missing lifetime specifier - f + f //~^ ERROR lifetime mismatch } // Test using `&Self` explicitly: async fn ref_Self(self: &Self, f: &u32) -> &u32 { - //~^ ERROR cannot infer an appropriate lifetime - //~| ERROR missing lifetime specifier - f + f //~^ ERROR lifetime mismatch } async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - //~^ ERROR cannot infer an appropriate lifetime - //~| ERROR missing lifetime specifier - f + f //~^ ERROR lifetime mismatch } async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - //~^ ERROR cannot infer an appropriate lifetime - //~| ERROR missing lifetime specifier - f + f //~^ ERROR lifetime mismatch } async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - //~^ ERROR cannot infer an appropriate lifetime - //~| ERROR missing lifetime specifier - f + f //~^ ERROR lifetime mismatch } async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { - //~^ ERROR cannot infer an appropriate lifetime - //~| ERROR missing lifetime specifier - f + f //~^ ERROR lifetime mismatch } } diff --git a/src/test/ui/self/elision/lt-ref-self-async.stderr b/src/test/ui/self/elision/lt-ref-self-async.stderr index 56595d008a6..0a459257fa7 100644 --- a/src/test/ui/self/elision/lt-ref-self-async.stderr +++ b/src/test/ui/self/elision/lt-ref-self-async.stderr @@ -1,159 +1,56 @@ -error[E0106]: missing lifetime specifier +error[E0623]: lifetime mismatch --> $DIR/lt-ref-self-async.rs:15:42 | LL | async fn ref_self(&self, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:23:48 +error[E0623]: lifetime mismatch + --> $DIR/lt-ref-self-async.rs:21:48 | LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier +error[E0623]: lifetime mismatch + --> $DIR/lt-ref-self-async.rs:25:57 + | +LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... + +error[E0623]: lifetime mismatch --> $DIR/lt-ref-self-async.rs:29:57 | -LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:35:57 - | LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:41:66 +error[E0623]: lifetime mismatch + --> $DIR/lt-ref-self-async.rs:33:66 | LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:47:62 +error[E0623]: lifetime mismatch + --> $DIR/lt-ref-self-async.rs:37:62 | LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/lt-ref-self-async.rs:15:30 - | -LL | async fn ref_self(&self, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 15:23 - --> $DIR/lt-ref-self-async.rs:15:23 - | -LL | async fn ref_self(&self, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 15:23 - | -LL | async fn ref_self(&self, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ +error: aborting due to 6 previous errors -error: cannot infer an appropriate lifetime - --> $DIR/lt-ref-self-async.rs:23:36 - | -LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 23:29 - --> $DIR/lt-ref-self-async.rs:23:29 - | -LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 23:29 - | -LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/lt-ref-self-async.rs:29:45 - | -LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 29:37 - --> $DIR/lt-ref-self-async.rs:29:37 - | -LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 29:37 - | -LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/lt-ref-self-async.rs:35:45 - | -LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 35:37 - --> $DIR/lt-ref-self-async.rs:35:37 - | -LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 35:37 - | -LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/lt-ref-self-async.rs:41:54 - | -LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 41:45 - --> $DIR/lt-ref-self-async.rs:41:45 - | -LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 41:45 - | -LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/lt-ref-self-async.rs:47:50 - | -LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 47:41 - --> $DIR/lt-ref-self-async.rs:47:41 - | -LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 47:41 - | -LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: aborting due to 12 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/multiple-ref-self-async.nll.stderr b/src/test/ui/self/elision/multiple-ref-self-async.nll.stderr deleted file mode 100644 index 00e16cd7f99..00000000000 --- a/src/test/ui/self/elision/multiple-ref-self-async.nll.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:24:74 - | -LL | async fn wrap_ref_Self_ref_Self(self: Wrap<&Self, &Self>, f: &u8) -> &u8 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:30:84 - | -LL | async fn box_wrap_ref_Self_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:36:84 - | -LL | async fn pin_wrap_ref_Self_ref_Self(self: Pin>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:42:93 - | -LL | async fn box_box_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:48:93 - | -LL | async fn box_pin_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/multiple-ref-self-async.rs b/src/test/ui/self/elision/multiple-ref-self-async.rs index 3cc146c5dc7..eb8c25277e1 100644 --- a/src/test/ui/self/elision/multiple-ref-self-async.rs +++ b/src/test/ui/self/elision/multiple-ref-self-async.rs @@ -1,3 +1,4 @@ +// check-pass // edition:2018 #![feature(async_await)] @@ -22,32 +23,22 @@ impl Struct { // Test using multiple `&Self`: async fn wrap_ref_Self_ref_Self(self: Wrap<&Self, &Self>, f: &u8) -> &u8 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_wrap_ref_Self_ref_Self(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn pin_wrap_ref_Self_ref_Self(self: Pin>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_box_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_pin_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } } diff --git a/src/test/ui/self/elision/multiple-ref-self-async.stderr b/src/test/ui/self/elision/multiple-ref-self-async.stderr deleted file mode 100644 index 2a89ed3feba..00000000000 --- a/src/test/ui/self/elision/multiple-ref-self-async.stderr +++ /dev/null @@ -1,133 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:24:74 - | -LL | async fn wrap_ref_Self_ref_Self(self: Wrap<&Self, &Self>, f: &u8) -> &u8 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:30:84 - | -LL | async fn box_wrap_ref_Self_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:36:84 - | -LL | async fn pin_wrap_ref_Self_ref_Self(self: Pin>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:42:93 - | -LL | async fn box_box_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:48:93 - | -LL | async fn box_pin_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: cannot infer an appropriate lifetime - --> $DIR/multiple-ref-self-async.rs:24:63 - | -LL | async fn wrap_ref_Self_ref_Self(self: Wrap<&Self, &Self>, f: &u8) -> &u8 { - | ^ --- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 24:48 - --> $DIR/multiple-ref-self-async.rs:24:48 - | -LL | async fn wrap_ref_Self_ref_Self(self: Wrap<&Self, &Self>, f: &u8) -> &u8 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 24:48 - | -LL | async fn wrap_ref_Self_ref_Self(self: Wrap<&Self, &Self>, f: &u8) -> &u8 + '_ { - | ^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/multiple-ref-self-async.rs:30:72 - | -LL | async fn box_wrap_ref_Self_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 30:56 - --> $DIR/multiple-ref-self-async.rs:30:56 - | -LL | async fn box_wrap_ref_Self_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 30:56 - | -LL | async fn box_wrap_ref_Self_ref_Self(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/multiple-ref-self-async.rs:36:72 - | -LL | async fn pin_wrap_ref_Self_ref_Self(self: Pin>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 36:56 - --> $DIR/multiple-ref-self-async.rs:36:56 - | -LL | async fn pin_wrap_ref_Self_ref_Self(self: Pin>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 36:56 - | -LL | async fn pin_wrap_ref_Self_ref_Self(self: Pin>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/multiple-ref-self-async.rs:42:81 - | -LL | async fn box_box_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 42:64 - --> $DIR/multiple-ref-self-async.rs:42:64 - | -LL | async fn box_box_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 42:64 - | -LL | async fn box_box_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/multiple-ref-self-async.rs:48:81 - | -LL | async fn box_pin_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 48:64 - --> $DIR/multiple-ref-self-async.rs:48:64 - | -LL | async fn box_pin_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 48:64 - | -LL | async fn box_pin_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: aborting due to 10 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-alias-async.nll.stderr b/src/test/ui/self/elision/ref-alias-async.nll.stderr deleted file mode 100644 index 7e47b379403..00000000000 --- a/src/test/ui/self/elision/ref-alias-async.nll.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:20:50 - | -LL | async fn ref_Alias(self: &Alias, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:26:59 - | -LL | async fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:32:59 - | -LL | async fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:38:68 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:44:68 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-alias-async.rs b/src/test/ui/self/elision/ref-alias-async.rs index 224151b9b0c..acc4b2153ef 100644 --- a/src/test/ui/self/elision/ref-alias-async.rs +++ b/src/test/ui/self/elision/ref-alias-async.rs @@ -1,4 +1,5 @@ // edition:2018 +// check-pass #![feature(async_await)] @@ -18,32 +19,22 @@ impl Struct { // feels like a bug. async fn ref_Alias(self: &Alias, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } } diff --git a/src/test/ui/self/elision/ref-alias-async.stderr b/src/test/ui/self/elision/ref-alias-async.stderr deleted file mode 100644 index a3250562c6f..00000000000 --- a/src/test/ui/self/elision/ref-alias-async.stderr +++ /dev/null @@ -1,133 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:20:50 - | -LL | async fn ref_Alias(self: &Alias, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:26:59 - | -LL | async fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:32:59 - | -LL | async fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:38:68 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:44:68 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: cannot infer an appropriate lifetime - --> $DIR/ref-alias-async.rs:20:38 - | -LL | async fn ref_Alias(self: &Alias, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 20:30 - --> $DIR/ref-alias-async.rs:20:30 - | -LL | async fn ref_Alias(self: &Alias, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 20:30 - | -LL | async fn ref_Alias(self: &Alias, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-alias-async.rs:26:47 - | -LL | async fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 26:38 - --> $DIR/ref-alias-async.rs:26:38 - | -LL | async fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 26:38 - | -LL | async fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-alias-async.rs:32:47 - | -LL | async fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 32:38 - --> $DIR/ref-alias-async.rs:32:38 - | -LL | async fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 32:38 - | -LL | async fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-alias-async.rs:38:56 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 38:46 - --> $DIR/ref-alias-async.rs:38:46 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 38:46 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-alias-async.rs:44:56 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 44:46 - --> $DIR/ref-alias-async.rs:44:46 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 44:46 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: aborting due to 10 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-assoc-async.nll.stderr b/src/test/ui/self/elision/ref-assoc-async.nll.stderr deleted file mode 100644 index 25c8bf652d8..00000000000 --- a/src/test/ui/self/elision/ref-assoc-async.nll.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:21:77 - | -LL | async fn ref_AssocType(self: &::AssocType, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:27:86 - | -LL | async fn box_ref_AssocType(self: Box<&::AssocType>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:33:86 - | -LL | async fn pin_ref_AssocType(self: Pin<&::AssocType>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:39:95 - | -LL | async fn box_box_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:45:95 - | -LL | async fn box_pin_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-assoc-async.rs b/src/test/ui/self/elision/ref-assoc-async.rs index 380937e61ca..a6b6cbd6da3 100644 --- a/src/test/ui/self/elision/ref-assoc-async.rs +++ b/src/test/ui/self/elision/ref-assoc-async.rs @@ -1,4 +1,5 @@ // edition:2018 +// check-pass #![feature(async_await)] @@ -19,32 +20,22 @@ impl Trait for Struct { impl Struct { async fn ref_AssocType(self: &::AssocType, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_ref_AssocType(self: Box<&::AssocType>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn pin_ref_AssocType(self: Pin<&::AssocType>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_box_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_pin_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } } diff --git a/src/test/ui/self/elision/ref-assoc-async.stderr b/src/test/ui/self/elision/ref-assoc-async.stderr deleted file mode 100644 index c2e893a3f58..00000000000 --- a/src/test/ui/self/elision/ref-assoc-async.stderr +++ /dev/null @@ -1,133 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:21:77 - | -LL | async fn ref_AssocType(self: &::AssocType, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:27:86 - | -LL | async fn box_ref_AssocType(self: Box<&::AssocType>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:33:86 - | -LL | async fn pin_ref_AssocType(self: Pin<&::AssocType>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:39:95 - | -LL | async fn box_box_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:45:95 - | -LL | async fn box_pin_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: cannot infer an appropriate lifetime - --> $DIR/ref-assoc-async.rs:21:65 - | -LL | async fn ref_AssocType(self: &::AssocType, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 21:34 - --> $DIR/ref-assoc-async.rs:21:34 - | -LL | async fn ref_AssocType(self: &::AssocType, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 21:34 - | -LL | async fn ref_AssocType(self: &::AssocType, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-assoc-async.rs:27:74 - | -LL | async fn box_ref_AssocType(self: Box<&::AssocType>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 27:42 - --> $DIR/ref-assoc-async.rs:27:42 - | -LL | async fn box_ref_AssocType(self: Box<&::AssocType>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 27:42 - | -LL | async fn box_ref_AssocType(self: Box<&::AssocType>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-assoc-async.rs:33:74 - | -LL | async fn pin_ref_AssocType(self: Pin<&::AssocType>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 33:42 - --> $DIR/ref-assoc-async.rs:33:42 - | -LL | async fn pin_ref_AssocType(self: Pin<&::AssocType>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 33:42 - | -LL | async fn pin_ref_AssocType(self: Pin<&::AssocType>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-assoc-async.rs:39:83 - | -LL | async fn box_box_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 39:50 - --> $DIR/ref-assoc-async.rs:39:50 - | -LL | async fn box_box_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 39:50 - | -LL | async fn box_box_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-assoc-async.rs:45:83 - | -LL | async fn box_pin_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 45:50 - --> $DIR/ref-assoc-async.rs:45:50 - | -LL | async fn box_pin_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 45:50 - | -LL | async fn box_pin_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: aborting due to 10 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-mut-alias-async.nll.stderr b/src/test/ui/self/elision/ref-mut-alias-async.nll.stderr deleted file mode 100644 index 1026a0b492f..00000000000 --- a/src/test/ui/self/elision/ref-mut-alias-async.nll.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:17:54 - | -LL | async fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:23:63 - | -LL | async fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:29:63 - | -LL | async fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:35:72 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:41:72 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-mut-alias-async.rs b/src/test/ui/self/elision/ref-mut-alias-async.rs index ce66313bddd..873e92bc6d3 100644 --- a/src/test/ui/self/elision/ref-mut-alias-async.rs +++ b/src/test/ui/self/elision/ref-mut-alias-async.rs @@ -1,7 +1,7 @@ // edition:2018 +// check-pass #![feature(async_await)] - #![feature(arbitrary_self_types)] #![allow(non_snake_case)] @@ -15,32 +15,22 @@ impl Struct { // Test using an alias for `Struct`: async fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } } diff --git a/src/test/ui/self/elision/ref-mut-alias-async.stderr b/src/test/ui/self/elision/ref-mut-alias-async.stderr deleted file mode 100644 index 678bf745186..00000000000 --- a/src/test/ui/self/elision/ref-mut-alias-async.stderr +++ /dev/null @@ -1,133 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:17:54 - | -LL | async fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:23:63 - | -LL | async fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:29:63 - | -LL | async fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:35:72 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:41:72 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-alias-async.rs:17:42 - | -LL | async fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 17:30 - --> $DIR/ref-mut-alias-async.rs:17:30 - | -LL | async fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 17:30 - | -LL | async fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-alias-async.rs:23:51 - | -LL | async fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 23:38 - --> $DIR/ref-mut-alias-async.rs:23:38 - | -LL | async fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 23:38 - | -LL | async fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-alias-async.rs:29:51 - | -LL | async fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 29:38 - --> $DIR/ref-mut-alias-async.rs:29:38 - | -LL | async fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 29:38 - | -LL | async fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-alias-async.rs:35:60 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 35:46 - --> $DIR/ref-mut-alias-async.rs:35:46 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 35:46 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-alias-async.rs:41:60 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 41:46 - --> $DIR/ref-mut-alias-async.rs:41:46 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 41:46 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: aborting due to 10 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-mut-self-async.rs b/src/test/ui/self/elision/ref-mut-self-async.rs index 7d143e1b35e..a6bd9d69316 100644 --- a/src/test/ui/self/elision/ref-mut-self-async.rs +++ b/src/test/ui/self/elision/ref-mut-self-async.rs @@ -12,42 +12,30 @@ struct Struct { } impl Struct { // Test using `&mut self` sugar: - async fn ref_self(&mut self, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime + async fn ref_self(&mut self, f: &u32) -> &u32 { //~ ERROR lifetime mismatch f } // Test using `&mut Self` explicitly: async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } } diff --git a/src/test/ui/self/elision/ref-mut-self-async.stderr b/src/test/ui/self/elision/ref-mut-self-async.stderr index 15f5f8dd0dd..d605bab4636 100644 --- a/src/test/ui/self/elision/ref-mut-self-async.stderr +++ b/src/test/ui/self/elision/ref-mut-self-async.stderr @@ -1,159 +1,56 @@ -error[E0106]: missing lifetime specifier +error[E0623]: lifetime mismatch --> $DIR/ref-mut-self-async.rs:15:46 | LL | async fn ref_self(&mut self, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | --------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:23:52 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-self-async.rs:24:52 | LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | --------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:29:61 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-self-async.rs:28:61 | LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | --------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:35:61 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-self-async.rs:32:61 | LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | --------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:41:70 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-self-async.rs:36:70 | LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | --------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:47:70 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-self-async.rs:40:70 | LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | --------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-self-async.rs:15:34 - | -LL | async fn ref_self(&mut self, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 15:23 - --> $DIR/ref-mut-self-async.rs:15:23 - | -LL | async fn ref_self(&mut self, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 15:23 - | -LL | async fn ref_self(&mut self, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ +error: aborting due to 6 previous errors -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-self-async.rs:23:40 - | -LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 23:29 - --> $DIR/ref-mut-self-async.rs:23:29 - | -LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 23:29 - | -LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-self-async.rs:29:49 - | -LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 29:37 - --> $DIR/ref-mut-self-async.rs:29:37 - | -LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 29:37 - | -LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-self-async.rs:35:49 - | -LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 35:37 - --> $DIR/ref-mut-self-async.rs:35:37 - | -LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 35:37 - | -LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-self-async.rs:41:58 - | -LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 41:45 - --> $DIR/ref-mut-self-async.rs:41:45 - | -LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 41:45 - | -LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-self-async.rs:47:58 - | -LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 47:45 - --> $DIR/ref-mut-self-async.rs:47:45 - | -LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 47:45 - | -LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: aborting due to 12 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-mut-struct-async.rs b/src/test/ui/self/elision/ref-mut-struct-async.rs index 3ba9c95d35f..7a89ef9596a 100644 --- a/src/test/ui/self/elision/ref-mut-struct-async.rs +++ b/src/test/ui/self/elision/ref-mut-struct-async.rs @@ -13,33 +13,23 @@ impl Struct { // Test using `&mut Struct` explicitly: async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } } diff --git a/src/test/ui/self/elision/ref-mut-struct-async.stderr b/src/test/ui/self/elision/ref-mut-struct-async.stderr index fd2581eba94..4c983872942 100644 --- a/src/test/ui/self/elision/ref-mut-struct-async.stderr +++ b/src/test/ui/self/elision/ref-mut-struct-async.stderr @@ -1,133 +1,47 @@ -error[E0106]: missing lifetime specifier +error[E0623]: lifetime mismatch --> $DIR/ref-mut-struct-async.rs:15:56 | LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ----------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:21:65 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-struct-async.rs:19:65 | LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ----------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:27:65 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-struct-async.rs:23:65 | LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ----------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:33:74 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-struct-async.rs:27:74 | LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ----------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:39:74 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-struct-async.rs:31:74 | LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ----------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-struct-async.rs:15:44 - | -LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 15:31 - --> $DIR/ref-mut-struct-async.rs:15:31 - | -LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 15:31 - | -LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ +error: aborting due to 5 previous errors -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-struct-async.rs:21:53 - | -LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 21:39 - --> $DIR/ref-mut-struct-async.rs:21:39 - | -LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 21:39 - | -LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-struct-async.rs:27:53 - | -LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 27:39 - --> $DIR/ref-mut-struct-async.rs:27:39 - | -LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 27:39 - | -LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-struct-async.rs:33:62 - | -LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 33:47 - --> $DIR/ref-mut-struct-async.rs:33:47 - | -LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 33:47 - | -LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-struct-async.rs:39:62 - | -LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 39:47 - --> $DIR/ref-mut-struct-async.rs:39:47 - | -LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 39:47 - | -LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: aborting due to 10 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-self-async.rs b/src/test/ui/self/elision/ref-self-async.rs index 6cca5494ff7..5a5705d7e09 100644 --- a/src/test/ui/self/elision/ref-self-async.rs +++ b/src/test/ui/self/elision/ref-self-async.rs @@ -21,48 +21,34 @@ impl Deref for Wrap { impl Struct { // Test using `&self` sugar: - async fn ref_self(&self, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime + async fn ref_self(&self, f: &u32) -> &u32 { //~ ERROR lifetime mismatch f } // Test using `&Self` explicitly: async fn ref_Self(self: &Self, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } } diff --git a/src/test/ui/self/elision/ref-self-async.stderr b/src/test/ui/self/elision/ref-self-async.stderr index eab77cfacd9..e169f3cf6f1 100644 --- a/src/test/ui/self/elision/ref-self-async.stderr +++ b/src/test/ui/self/elision/ref-self-async.stderr @@ -1,185 +1,65 @@ -error[E0106]: missing lifetime specifier +error[E0623]: lifetime mismatch --> $DIR/ref-self-async.rs:24:42 | LL | async fn ref_self(&self, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:32:48 +error[E0623]: lifetime mismatch + --> $DIR/ref-self-async.rs:33:48 | LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:38:57 +error[E0623]: lifetime mismatch + --> $DIR/ref-self-async.rs:37:57 | LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:44:57 +error[E0623]: lifetime mismatch + --> $DIR/ref-self-async.rs:41:57 | LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:50:66 +error[E0623]: lifetime mismatch + --> $DIR/ref-self-async.rs:45:66 | LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:56:66 +error[E0623]: lifetime mismatch + --> $DIR/ref-self-async.rs:49:66 | LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:62:69 +error[E0623]: lifetime mismatch + --> $DIR/ref-self-async.rs:53:69 | LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ----- ^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-self-async.rs:24:30 - | -LL | async fn ref_self(&self, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 24:23 - --> $DIR/ref-self-async.rs:24:23 - | -LL | async fn ref_self(&self, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 24:23 - | -LL | async fn ref_self(&self, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ +error: aborting due to 7 previous errors -error: cannot infer an appropriate lifetime - --> $DIR/ref-self-async.rs:32:36 - | -LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 32:29 - --> $DIR/ref-self-async.rs:32:29 - | -LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 32:29 - | -LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-self-async.rs:38:45 - | -LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 38:37 - --> $DIR/ref-self-async.rs:38:37 - | -LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 38:37 - | -LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-self-async.rs:44:45 - | -LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 44:37 - --> $DIR/ref-self-async.rs:44:37 - | -LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 44:37 - | -LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-self-async.rs:50:54 - | -LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 50:45 - --> $DIR/ref-self-async.rs:50:45 - | -LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 50:45 - | -LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-self-async.rs:56:54 - | -LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 56:45 - --> $DIR/ref-self-async.rs:56:45 - | -LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 56:45 - | -LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-self-async.rs:62:58 - | -LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { - | ^ --- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 62:44 - --> $DIR/ref-self-async.rs:62:44 - | -LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 62:44 - | -LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 + '_ { - | ^^^^^^^^ - -error: aborting due to 14 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-struct-async.rs b/src/test/ui/self/elision/ref-struct-async.rs index cd0f5a2a605..f0410bbee90 100644 --- a/src/test/ui/self/elision/ref-struct-async.rs +++ b/src/test/ui/self/elision/ref-struct-async.rs @@ -13,33 +13,23 @@ impl Struct { // Test using `&Struct` explicitly: async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } } diff --git a/src/test/ui/self/elision/ref-struct-async.stderr b/src/test/ui/self/elision/ref-struct-async.stderr index 966e102fa5f..574b0fddc1e 100644 --- a/src/test/ui/self/elision/ref-struct-async.stderr +++ b/src/test/ui/self/elision/ref-struct-async.stderr @@ -1,133 +1,47 @@ -error[E0106]: missing lifetime specifier +error[E0623]: lifetime mismatch --> $DIR/ref-struct-async.rs:15:52 | LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:21:61 +error[E0623]: lifetime mismatch + --> $DIR/ref-struct-async.rs:19:61 | LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:27:61 +error[E0623]: lifetime mismatch + --> $DIR/ref-struct-async.rs:23:61 | LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:33:70 +error[E0623]: lifetime mismatch + --> $DIR/ref-struct-async.rs:27:70 | LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:39:66 +error[E0623]: lifetime mismatch + --> $DIR/ref-struct-async.rs:31:66 | LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-struct-async.rs:15:40 - | -LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 15:31 - --> $DIR/ref-struct-async.rs:15:31 - | -LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 15:31 - | -LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ +error: aborting due to 5 previous errors -error: cannot infer an appropriate lifetime - --> $DIR/ref-struct-async.rs:21:49 - | -LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 21:39 - --> $DIR/ref-struct-async.rs:21:39 - | -LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 21:39 - | -LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-struct-async.rs:27:49 - | -LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 27:39 - --> $DIR/ref-struct-async.rs:27:39 - | -LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 27:39 - | -LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-struct-async.rs:33:58 - | -LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 33:47 - --> $DIR/ref-struct-async.rs:33:47 - | -LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 33:47 - | -LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-struct-async.rs:39:54 - | -LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 39:43 - --> $DIR/ref-struct-async.rs:39:43 - | -LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 39:43 - | -LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: aborting due to 10 previous errors - -For more information about this error, try `rustc --explain E0106`.