From 03e7b9628199f5c82d083cd02116c4424a31f47f Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 12 Aug 2019 17:15:33 -0400 Subject: [PATCH 1/5] 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`. From 948739f2eef514357a0f1ab2eb12d6bdb05a7d41 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 12 Aug 2019 19:21:13 -0400 Subject: [PATCH 2/5] revamp comment --- src/librustc/hir/lowering.rs | 76 +++++++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 15 deletions(-) diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 8e7f96ca236..89017386374 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -2570,7 +2570,54 @@ impl<'a> LoweringContext<'a> { self.allocate_hir_id_counter(opaque_ty_node_id); + // When we create the opaque type for this async fn, it is going to have + // to capture all the lifetimes involved in the signature (including in the + // return type). This is done by introducing lifetime parameters for: + // + // - all the explicitly declared lifetimes from the impl and function itself; + // - all the elided lifetimes in the fn arguments; + // - all the elided lifetimes in the return type. + // + // So for example in this snippet: + // + // ```rust + // impl<'a> Foo<'a> { + // async fn bar<'b>(&self, x: &'b Vec, y: &str) -> &u32 { + // // ^ '0 ^ '1 ^ '2 + // // elided lifetimes used below + // } + // } + // ``` + // + // we would create an opaque type like: + // + // ``` + // type Bar<'a, 'b, '0, '1, '2> = impl Future; + // ``` + // + // and we would then desugar `bar` to the equivalent of: + // + // ```rust + // impl<'a> Foo<'a> { + // fn bar<'b, '0, '1>(&'0 self, x: &'b Vec, y: &'1 str) -> Bar<'a, 'b, '0, '1, '_> + // } + // ``` + // + // Note that the final parameter to `Bar` is `'_`, not `'2` -- + // this is because the elided lifetimes from the return type + // should be figured out using the ordinary elision rules, and + // this desugaring achieves that. + // + // The variable `input_lifetimes_count` tracks the number of + // lifetime parameters to the opaque type *not counting* those + // lifetimes elided in the return type. This includes those + // that are explicitly declared (`in_scope_lifetimes`) and + // those elided lifetimes we found in the arguments (current + // content of `lifetimes_to_define`). Next, we will process + // the return type, which will cause `lifetimes_to_define` to + // grow. 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 @@ -2635,29 +2682,27 @@ impl<'a> LoweringContext<'a> { (opaque_ty_id, lifetime_params) }); - // Create the generic lifetime arguments that we will supply - // to the opaque return type. Consider: + // As documented above on the variable + // `input_lifetimes_count`, we need to create the lifetime + // arguments to our opaque type. Continuing with our example, + // we're creating the type arguments for the return type: // - // ```rust - // async fn foo(x: &u32, ) -> &[&u32] { .. } + // ``` + // Bar<'a, 'b, '0, '1, '_> // ``` // - // Here, we would create something like: + // For the "input" lifetime parameters, we wish to create + // references to the parameters themselves, including the + // "implicit" ones created from parameter types (`'a`, `'b`, + // '`0`, `'1`). // - // ```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. + // For the "output" lifetime parameters, we just want to + // generate `'_`. let mut generic_args: Vec<_> = lifetime_params[..input_lifetimes_count] .iter() .map(|&(span, hir_name)| { + // Input lifetime like `'a` or `'1`: GenericArg::Lifetime(hir::Lifetime { hir_id: self.next_id(), span, @@ -2669,6 +2714,7 @@ impl<'a> LoweringContext<'a> { lifetime_params[input_lifetimes_count..] .iter() .map(|&(span, _)| { + // Output lifetime like `'_`. GenericArg::Lifetime(hir::Lifetime { hir_id: self.next_id(), span, From ad214fe47092c5b3d36a58480f6fa3f62d20770b Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 12 Aug 2019 19:23:21 -0400 Subject: [PATCH 3/5] fix README.md --- src/test/ui/self/elision/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/ui/self/elision/README.md b/src/test/ui/self/elision/README.md index 2db8a23be6e..3bd7a6c00b2 100644 --- a/src/test/ui/self/elision/README.md +++ b/src/test/ui/self/elision/README.md @@ -61,10 +61,10 @@ Legends: | `struct-async.rs`| ✓ | ✓ | N/A | | `alias-async.rs`| ✓ | ✓ | N/A | | `assoc-async.rs`| ✓ | ✓ | N/A | -| `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-self-async.rs` | X | ✓ | N/A | +| `ref-mut-self-async.rs` | X | ✓ | N/A | +| `ref-struct-async.rs` | X | ✓ | N/A | +| `ref-mut-struct-async.rs` | X | ✓ | N/A | | `ref-alias-async.rs` | ✓ | ✓ | N/A | | `ref-assoc-async.rs` | ✓ | ✓ | N/A | | `ref-mut-alias-async.rs` | ✓ | ✓ | N/A | @@ -72,4 +72,4 @@ Legends: | `lt-struct-async.rs` | ✓ | ✓ | N/A | `lt-alias-async.rs` | ✓ | ✓ | N/A | `lt-assoc-async.rs` | ✓ | ✓ | N/A -| `lt-ref-self-async.rs` | ✓ | ✓ | N/A | +| `lt-ref-self-async.rs` | X | ✓ | N/A | From d7c7c52dbc462048cb60d4dca43b42d753025a6b Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 12 Aug 2019 21:13:59 -0400 Subject: [PATCH 4/5] bless tests --- ..._self_types_pin_lifetime_mismatch-async.rs | 10 +- ...f_types_pin_lifetime_mismatch-async.stderr | 91 ++++--------------- .../ui/self/elision/ref-mut-self-async.stderr | 10 +- .../ui/self/elision/ref-self-async.stderr | 12 +-- .../ui/self/self_lifetime-async.nll.stderr | 11 --- src/test/ui/self/self_lifetime-async.rs | 6 +- src/test/ui/self/self_lifetime-async.stderr | 39 -------- 7 files changed, 30 insertions(+), 149 deletions(-) delete mode 100644 src/test/ui/self/self_lifetime-async.nll.stderr delete mode 100644 src/test/ui/self/self_lifetime-async.stderr diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.rs b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.rs index 93870b7cdcf..53ab75ee16b 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.rs +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.rs @@ -8,16 +8,10 @@ struct Foo; impl Foo { async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - // FIXME: should be E0623? + //~^ ERROR lifetime mismatch async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - //~| ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - // FIXME: should be E0623? + //~^ ERROR lifetime mismatch } type Alias = Pin; diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr index c7d10e7fc78..74fc4741349 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr @@ -1,81 +1,23 @@ -error[E0106]: missing lifetime specifier +error[E0623]: lifetime mismatch --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:10:45 | LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:60 - | -LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:67 - | -LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: cannot infer an appropriate lifetime - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:10:33 - | -LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 10:26 - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:10:26 - | -LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } - | ^ -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 10:26 - | -LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo + '_ { f } - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:16 - | -LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ^^^^ ...but this borrow... ----------------- this return type evaluates to the `'static` lifetime... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 15:26 - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:26 - | -LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ^ -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:26 - | -LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) + '_ { (self, f) } - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:34 - | -LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ^ ----------------- 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:26 - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:26 - | -LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ^ -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:26 - | -LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) + '_ { (self, f) } - | ^^^^^^^^^^^^^^^^^^^^^^ + | ---- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:25:58 + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:13:55 + | +LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } + | ----- ^^^^^^^^^^^^^^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... + +error[E0623]: lifetime mismatch + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:19:58 | LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } | ----- ^^^ @@ -83,6 +25,5 @@ LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } | | ...but data from `arg` is returned here | this parameter and the return type are declared with different lifetimes... -error: aborting due to 7 previous errors +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0106`. 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 d605bab4636..805833f9472 100644 --- a/src/test/ui/self/elision/ref-mut-self-async.stderr +++ b/src/test/ui/self/elision/ref-mut-self-async.stderr @@ -8,7 +8,7 @@ LL | async fn ref_self(&mut self, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-mut-self-async.rs:24:52 + --> $DIR/ref-mut-self-async.rs:21:52 | LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { | --------- ^^^^ @@ -17,7 +17,7 @@ LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-mut-self-async.rs:28:61 + --> $DIR/ref-mut-self-async.rs:25:61 | LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { | --------- ^^^^ @@ -26,7 +26,7 @@ LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-mut-self-async.rs:32:61 + --> $DIR/ref-mut-self-async.rs:29:61 | LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { | --------- ^^^^ @@ -35,7 +35,7 @@ LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-mut-self-async.rs:36:70 + --> $DIR/ref-mut-self-async.rs:33:70 | LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | --------- ^^^^ @@ -44,7 +44,7 @@ LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-mut-self-async.rs:40:70 + --> $DIR/ref-mut-self-async.rs:37:70 | LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { | --------- ^^^^ diff --git a/src/test/ui/self/elision/ref-self-async.stderr b/src/test/ui/self/elision/ref-self-async.stderr index e169f3cf6f1..eb796a07a86 100644 --- a/src/test/ui/self/elision/ref-self-async.stderr +++ b/src/test/ui/self/elision/ref-self-async.stderr @@ -8,7 +8,7 @@ LL | async fn ref_self(&self, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:33:48 + --> $DIR/ref-self-async.rs:30:48 | LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { | ----- ^^^^ @@ -17,7 +17,7 @@ LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:37:57 + --> $DIR/ref-self-async.rs:34:57 | LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | ----- ^^^^ @@ -26,7 +26,7 @@ LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:41:57 + --> $DIR/ref-self-async.rs:38:57 | LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | ----- ^^^^ @@ -35,7 +35,7 @@ LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:45:66 + --> $DIR/ref-self-async.rs:42:66 | LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | ----- ^^^^ @@ -44,7 +44,7 @@ LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:49:66 + --> $DIR/ref-self-async.rs:46:66 | LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { | ----- ^^^^ @@ -53,7 +53,7 @@ LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:53:69 + --> $DIR/ref-self-async.rs:50:69 | LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { | ----- ^^^ diff --git a/src/test/ui/self/self_lifetime-async.nll.stderr b/src/test/ui/self/self_lifetime-async.nll.stderr deleted file mode 100644 index 805d2433f87..00000000000 --- a/src/test/ui/self/self_lifetime-async.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/self_lifetime-async.rs:9:44 - | -LL | async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 } - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found none. - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/self_lifetime-async.rs b/src/test/ui/self/self_lifetime-async.rs index 71eba01fe1a..ec4c3d15224 100644 --- a/src/test/ui/self/self_lifetime-async.rs +++ b/src/test/ui/self/self_lifetime-async.rs @@ -1,5 +1,4 @@ -// FIXME: Investigate why `self_lifetime.rs` is check-pass but this isn't. - +// check-pass // edition:2018 #![feature(async_await)] @@ -7,14 +6,11 @@ struct Foo<'a>(&'a ()); impl<'a> Foo<'a> { async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 } - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime } type Alias = Foo<'static>; impl Alias { async fn bar<'a>(self: &Alias, arg: &'a ()) -> &() { arg } - //~^ ERROR lifetime mismatch } fn main() {} diff --git a/src/test/ui/self/self_lifetime-async.stderr b/src/test/ui/self/self_lifetime-async.stderr deleted file mode 100644 index e3ec1abd447..00000000000 --- a/src/test/ui/self/self_lifetime-async.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/self_lifetime-async.rs:9:44 - | -LL | async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 } - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found none. - -error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/self_lifetime-async.rs:9:22 - | -LL | async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 } - | ^^^^ - | -note: first, the lifetime cannot outlive the lifetime 'a as defined on the impl at 8:6... - --> $DIR/self_lifetime-async.rs:8:6 - | -LL | impl<'a> Foo<'a> { - | ^^ - = note: ...so that the expression is assignable: - expected &Foo<'_> - found &'b Foo<'a> - = note: but, the lifetime must be valid for the static lifetime... - = note: ...so that the types are compatible: - expected &() - found &'static () - -error[E0623]: lifetime mismatch - --> $DIR/self_lifetime-async.rs:16:52 - | -LL | async fn bar<'a>(self: &Alias, arg: &'a ()) -> &() { arg } - | ------ ^^^ - | | | - | | ...but data from `arg` is returned here - | this parameter and the return type are declared with different lifetimes... - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0106`. From 18d69c8ebe7b313d574014e6585680f78bd2e157 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 13 Aug 2019 09:13:50 -0400 Subject: [PATCH 5/5] bless tests with compare-mode=nll --- .../issues/issue-63388-1.nll.stderr | 24 +++ .../issues/issue-63388-2.nll.stderr | 11 ++ ...pes_pin_lifetime_mismatch-async.nll.stderr | 49 ++++-- .../self/elision/lt-ref-self-async.nll.stderr | 122 ++++++++++++--- .../elision/ref-mut-self-async.nll.stderr | 122 ++++++++++++--- .../elision/ref-mut-struct-async.nll.stderr | 102 ++++++++++--- .../ui/self/elision/ref-self-async.nll.stderr | 142 ++++++++++++++---- .../self/elision/ref-struct-async.nll.stderr | 102 ++++++++++--- 8 files changed, 538 insertions(+), 136 deletions(-) create mode 100644 src/test/ui/async-await/issues/issue-63388-1.nll.stderr create mode 100644 src/test/ui/async-await/issues/issue-63388-2.nll.stderr diff --git a/src/test/ui/async-await/issues/issue-63388-1.nll.stderr b/src/test/ui/async-await/issues/issue-63388-1.nll.stderr new file mode 100644 index 00000000000..fab5892dae1 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-63388-1.nll.stderr @@ -0,0 +1,24 @@ +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/issue-63388-1.rs:14:10 + | +LL | ) -> &dyn Foo + | ^^^^^^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#27r + +error: lifetime may not live long enough + --> $DIR/issue-63388-1.rs:15:5 + | +LL | async fn do_sth<'a>( + | -- lifetime `'a` defined here +LL | &'a self, foo: &dyn Foo + | - lifetime `'_` defined here +LL | ) -> &dyn Foo +LL | / { +LL | | foo +LL | | } + | |_____^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'_` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/async-await/issues/issue-63388-2.nll.stderr b/src/test/ui/async-await/issues/issue-63388-2.nll.stderr new file mode 100644 index 00000000000..b91cdc1b770 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-63388-2.nll.stderr @@ -0,0 +1,11 @@ +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: aborting due to previous error + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr index 65856095556..94646c2cfe0 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr @@ -1,27 +1,46 @@ -error[E0106]: missing lifetime specifier +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:10:45 | LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } - | ^ + | ^^^^ | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:60 +error: lifetime may not live long enough + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:10:50 + | +LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } + | - ^^^^^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + | | + | lifetime `'_` defined here + | lifetime `'_` defined here + +error: lifetime may not live long enough + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:13:73 | LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | - ^^^^^^^^^^^^^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + | | + | lifetime `'_` defined here + | lifetime `'_` defined here -error[E0106]: missing lifetime specifier - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:67 +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:19:58 | -LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ^ +LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } + | ^^^ | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error: aborting due to 3 previous errors +error: lifetime may not live long enough + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:19:62 + | +LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } + | -- - ^^^^^^^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'a` + | | | + | | lifetime `'_` defined here + | lifetime `'a` defined here -For more information about this error, try `rustc --explain E0106`. +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/self/elision/lt-ref-self-async.nll.stderr b/src/test/ui/self/elision/lt-ref-self-async.nll.stderr index d3aeb73b9b7..779b21e21a0 100644 --- a/src/test/ui/self/elision/lt-ref-self-async.nll.stderr +++ b/src/test/ui/self/elision/lt-ref-self-async.nll.stderr @@ -1,51 +1,123 @@ -error[E0106]: missing lifetime specifier +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds --> $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. + = note: hidden type `impl std::future::Future` captures lifetime '_#28r -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:23:48 +error: lifetime may not live long enough + --> $DIR/lt-ref-self-async.rs:15:47 + | +LL | async fn ref_self(&self, f: &u32) -> &u32 { + | _______________________-_______________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $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. + = note: hidden type `impl std::future::Future` captures lifetime '_#28r -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:29:57 +error: lifetime may not live long enough + --> $DIR/lt-ref-self-async.rs:21:53 + | +LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { + | _____________________________-_______________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/lt-ref-self-async.rs:25: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. + = note: hidden type `impl std::future::Future` captures lifetime '_#28r -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:35:57 +error: lifetime may not live long enough + --> $DIR/lt-ref-self-async.rs:25:62 + | +LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { + | _____________________________________-________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/lt-ref-self-async.rs:29: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. + = note: hidden type `impl std::future::Future` captures lifetime '_#28r -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:41:66 +error: lifetime may not live long enough + --> $DIR/lt-ref-self-async.rs:29:62 + | +LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { + | _____________________________________-________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $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. + = note: hidden type `impl std::future::Future` captures lifetime '_#28r -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:47:62 +error: lifetime may not live long enough + --> $DIR/lt-ref-self-async.rs:33:71 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + | _____________________________________________-_________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $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. + = note: hidden type `impl std::future::Future` captures lifetime '_#28r -error: aborting due to 6 previous errors +error: lifetime may not live long enough + --> $DIR/lt-ref-self-async.rs:37:67 + | +LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { + | _________________________________________-_________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -For more information about this error, try `rustc --explain E0106`. +error: aborting due to 12 previous errors + +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/self/elision/ref-mut-self-async.nll.stderr b/src/test/ui/self/elision/ref-mut-self-async.nll.stderr index 35969659b19..cfe91dde373 100644 --- a/src/test/ui/self/elision/ref-mut-self-async.nll.stderr +++ b/src/test/ui/self/elision/ref-mut-self-async.nll.stderr @@ -1,51 +1,123 @@ -error[E0106]: missing lifetime specifier +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds --> $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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:23:52 +error: lifetime may not live long enough + --> $DIR/ref-mut-self-async.rs:15:51 + | +LL | async fn ref_self(&mut self, f: &u32) -> &u32 { + | _______________________-___________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-mut-self-async.rs:21: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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:29:61 +error: lifetime may not live long enough + --> $DIR/ref-mut-self-async.rs:21:57 + | +LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { + | _____________________________-___________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-mut-self-async.rs:25: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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:35:61 +error: lifetime may not live long enough + --> $DIR/ref-mut-self-async.rs:25:66 + | +LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { + | _____________________________________-____________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-mut-self-async.rs:29: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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:41:70 +error: lifetime may not live long enough + --> $DIR/ref-mut-self-async.rs:29:66 + | +LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { + | _____________________________________-____________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-mut-self-async.rs:33: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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:47:70 +error: lifetime may not live long enough + --> $DIR/ref-mut-self-async.rs:33:75 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + | _____________________________________________-_____________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-mut-self-async.rs:37: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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error: aborting due to 6 previous errors +error: lifetime may not live long enough + --> $DIR/ref-mut-self-async.rs:37:75 + | +LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { + | _____________________________________________-_____________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -For more information about this error, try `rustc --explain E0106`. +error: aborting due to 12 previous errors + +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr b/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr index a70dcf5b0ad..98fa5e25451 100644 --- a/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr +++ b/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr @@ -1,43 +1,103 @@ -error[E0106]: missing lifetime specifier +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds --> $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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:21:65 +error: lifetime may not live long enough + --> $DIR/ref-mut-struct-async.rs:15:61 + | +LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { + | _______________________________-_____________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:27:65 +error: lifetime may not live long enough + --> $DIR/ref-mut-struct-async.rs:19:70 + | +LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { + | _______________________________________-______________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:33:74 +error: lifetime may not live long enough + --> $DIR/ref-mut-struct-async.rs:23:70 + | +LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { + | _______________________________________-______________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:39:74 +error: lifetime may not live long enough + --> $DIR/ref-mut-struct-async.rs:27:79 + | +LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { + | _______________________________________________-_______________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error: aborting due to 5 previous errors +error: lifetime may not live long enough + --> $DIR/ref-mut-struct-async.rs:31:79 + | +LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { + | _______________________________________________-_______________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -For more information about this error, try `rustc --explain E0106`. +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/self/elision/ref-self-async.nll.stderr b/src/test/ui/self/elision/ref-self-async.nll.stderr index ae17ba9839d..f991f6d9f7f 100644 --- a/src/test/ui/self/elision/ref-self-async.nll.stderr +++ b/src/test/ui/self/elision/ref-self-async.nll.stderr @@ -1,59 +1,143 @@ -error[E0106]: missing lifetime specifier +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds --> $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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:32:48 +error: lifetime may not live long enough + --> $DIR/ref-self-async.rs:24:47 + | +LL | async fn ref_self(&self, f: &u32) -> &u32 { + | _______________________-_______________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-self-async.rs:30: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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:38:57 +error: lifetime may not live long enough + --> $DIR/ref-self-async.rs:30:53 + | +LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { + | _____________________________-_______________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-self-async.rs:34: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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:44:57 +error: lifetime may not live long enough + --> $DIR/ref-self-async.rs:34:62 + | +LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { + | _____________________________________-________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-self-async.rs:38: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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:50:66 +error: lifetime may not live long enough + --> $DIR/ref-self-async.rs:38:62 + | +LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { + | _____________________________________-________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-self-async.rs:42: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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:56:66 +error: lifetime may not live long enough + --> $DIR/ref-self-async.rs:42:71 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + | _____________________________________________-_________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-self-async.rs:46: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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:62:69 +error: lifetime may not live long enough + --> $DIR/ref-self-async.rs:46:71 + | +LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { + | _____________________________________________-_________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-self-async.rs:50: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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error: aborting due to 7 previous errors +error: lifetime may not live long enough + --> $DIR/ref-self-async.rs:50:73 + | +LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { + | ____________________________________________-____________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -For more information about this error, try `rustc --explain E0106`. +error: aborting due to 14 previous errors + +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/self/elision/ref-struct-async.nll.stderr b/src/test/ui/self/elision/ref-struct-async.nll.stderr index b4f12d7057d..437d403e044 100644 --- a/src/test/ui/self/elision/ref-struct-async.nll.stderr +++ b/src/test/ui/self/elision/ref-struct-async.nll.stderr @@ -1,43 +1,103 @@ -error[E0106]: missing lifetime specifier +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds --> $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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:21:61 +error: lifetime may not live long enough + --> $DIR/ref-struct-async.rs:15:57 + | +LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { + | _______________________________-_________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:27:61 +error: lifetime may not live long enough + --> $DIR/ref-struct-async.rs:19:66 + | +LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { + | _______________________________________-__________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:33:70 +error: lifetime may not live long enough + --> $DIR/ref-struct-async.rs:23:66 + | +LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { + | _______________________________________-__________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:39:66 +error: lifetime may not live long enough + --> $DIR/ref-struct-async.rs:27:75 + | +LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { + | _______________________________________________-___________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $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. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error: aborting due to 5 previous errors +error: lifetime may not live long enough + --> $DIR/ref-struct-async.rs:31:71 + | +LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { + | ___________________________________________-___________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -For more information about this error, try `rustc --explain E0106`. +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0700`.