diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index fe69c9e634635..803a2ebbb012d 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -337,49 +337,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]> } @@ -1953,8 +1910,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, @@ -2141,7 +2097,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() @@ -2156,16 +2111,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 { @@ -2230,7 +2179,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(); @@ -2248,9 +2196,65 @@ 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 + // 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, @@ -2304,19 +2308,52 @@ 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), - }) + // 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: + // + // ``` + // Bar<'a, 'b, '0, '1, '_> + // ``` + // + // 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`). + // + // 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, + name: hir::LifetimeName::Param(hir_name), }) - .collect(); + }) + .collect(); + generic_args.extend( + lifetime_params[input_lifetimes_count..] + .iter() + .map(|&(span, _)| { + // Output lifetime like `'_`. + 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, @@ -2412,11 +2449,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); @@ -2439,39 +2471,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], @@ -3174,10 +3173,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) - } } } @@ -3231,10 +3226,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), } } @@ -3266,25 +3257,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.nll.stderr b/src/test/ui/async-await/issues/issue-63388-1.nll.stderr new file mode 100644 index 0000000000000..fab5892dae183 --- /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-1.rs b/src/test/ui/async-await/issues/issue-63388-1.rs new file mode 100644 index 0000000000000..80003b0d701f5 --- /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 0000000000000..5302adce5a01e --- /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.nll.stderr b/src/test/ui/async-await/issues/issue-63388-2.nll.stderr new file mode 100644 index 0000000000000..b91cdc1b770fb --- /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/async-await/issues/issue-63388-2.rs b/src/test/ui/async-await/issues/issue-63388-2.rs new file mode 100644 index 0000000000000..ca9bbef0d503d --- /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 0000000000000..1810138dc80e0 --- /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 0000000000000..05f23f95965b9 --- /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 0000000000000..0939242d7fc7a --- /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/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr index 6585609555675..94646c2cfe0c3 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 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. +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[E0106]: missing lifetime specifier - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:67 +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) } - | ^ + | - ^^^^^^^^^^^^^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + | | + | lifetime `'_` defined here + | lifetime `'_` defined here + +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 bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } + | ^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:19:62 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +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 -error: aborting due to 3 previous errors +error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0106`. +For more information about this error, try `rustc --explain E0700`. 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 93870b7cdcf28..53ab75ee16bd0 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 c7d10e7fc780d..74fc474134949 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. + | ---- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -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 +error[E0623]: lifetime mismatch + --> $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) } - | ^ -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: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/README.md b/src/test/ui/self/elision/README.md index c4f06433ba709..3bd7a6c00b2ad 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` | 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 | | `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` | X | ✓ | N/A | 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 d3aeb73b9b7c2..779b21e21a097 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: hidden type `impl std::future::Future` captures lifetime '_#28r + +error: lifetime may not live long enough + --> $DIR/lt-ref-self-async.rs:25:62 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +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[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:35:57 +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: hidden type `impl std::future::Future` captures lifetime '_#28r + +error: lifetime may not live long enough + --> $DIR/lt-ref-self-async.rs:29:62 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +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[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:41:66 +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: hidden type `impl std::future::Future` captures lifetime '_#28r + +error: lifetime may not live long enough + --> $DIR/lt-ref-self-async.rs:37:67 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +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 `'_` -error: aborting due to 6 previous errors +error: aborting due to 12 previous errors -For more information about this error, try `rustc --explain E0106`. +For more information about this error, try `rustc --explain E0700`. 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 84b91ba08b75d..79a4771978a8e 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 56595d008a6bf..0a459257fa708 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. - -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:23: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. - -error[E0106]: missing lifetime specifier - --> $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. - -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:41: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. - -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:47: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. - -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 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...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: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 +error[E0623]: lifetime mismatch + --> $DIR/lt-ref-self-async.rs:21:48 | 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 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...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: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 +error[E0623]: lifetime mismatch + --> $DIR/lt-ref-self-async.rs:25:57 | 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 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...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: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 +error[E0623]: lifetime mismatch + --> $DIR/lt-ref-self-async.rs:29:57 | 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 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...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: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 +error[E0623]: lifetime mismatch + --> $DIR/lt-ref-self-async.rs:33:66 | 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 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...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: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 +error[E0623]: lifetime mismatch + --> $DIR/lt-ref-self-async.rs:37:62 | 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 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: aborting due to 12 previous errors +error: aborting due to 6 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 00e16cd7f99fb..0000000000000 --- 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 3cc146c5dc7b2..eb8c25277e145 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 2a89ed3feba62..0000000000000 --- 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 7e47b3794035f..0000000000000 --- 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 224151b9b0c55..acc4b2153ef66 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 a3250562c6fff..0000000000000 --- 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 25c8bf652d84b..0000000000000 --- 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 380937e61ca3f..a6b6cbd6da391 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 c2e893a3f58bf..0000000000000 --- 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 1026a0b492f34..0000000000000 --- 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 ce66313bddd12..873e92bc6d33e 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 678bf74518606..0000000000000 --- 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.nll.stderr b/src/test/ui/self/elision/ref-mut-self-async.nll.stderr index 35969659b19d1..cfe91dde37354 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: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-mut-self-async.rs:25:66 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +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[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:35:61 +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: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-mut-self-async.rs:29:66 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +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[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:41:70 +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: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-mut-self-async.rs:37:75 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +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: aborting due to 6 previous errors +error: aborting due to 12 previous errors -For more information about this error, try `rustc --explain E0106`. +For more information about this error, try `rustc --explain E0700`. 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 7d143e1b35e45..a6bd9d693163e 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 15f5f8dd0dd48..805833f94720d 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. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:23: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. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:29: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. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:35: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. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:41: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. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:47: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. - -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 + '_ { - | ^^^^^^^^^ + | --------- ^^^^ + | | | + | | ...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: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 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-self-async.rs:21:52 | 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 + '_ { - | ^^^^^^^^^ + | --------- ^^^^ + | | | + | | ...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: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 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-self-async.rs:25:61 | 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 + '_ { - | ^^^^^^^^^ + | --------- ^^^^ + | | | + | | ...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: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 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-self-async.rs:29:61 | 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 + '_ { - | ^^^^^^^^^ + | --------- ^^^^ + | | | + | | ...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: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 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-self-async.rs:33:70 | 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 + '_ { - | ^^^^^^^^^ + | --------- ^^^^ + | | | + | | ...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: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 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-self-async.rs:37:70 | 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 + '_ { - | ^^^^^^^^^ + | --------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: aborting due to 12 previous errors +error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0106`. 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 a70dcf5b0ad19..98fa5e2545186 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: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-mut-struct-async.rs:23:70 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +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[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:33:74 +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: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-mut-struct-async.rs:27:79 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +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[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:39:74 +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: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-mut-struct-async.rs:31:79 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +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 `'_` -error: aborting due to 5 previous errors +error: aborting due to 10 previous errors -For more information about this error, try `rustc --explain E0106`. +For more information about this error, try `rustc --explain E0700`. 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 3ba9c95d35ff4..7a89ef9596a37 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 fd2581eba9434..4c983872942c1 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. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:21: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. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:27: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. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:33: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. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:39: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. - -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 + '_ { - | ^^^^^^^^^ + | ----------- ^^^^ + | | | + | | ...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: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 +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 { - | ^ -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 + '_ { - | ^^^^^^^^^ + | ----------- ^^^^ + | | | + | | ...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: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 +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 { - | ^ -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 + '_ { - | ^^^^^^^^^ + | ----------- ^^^^ + | | | + | | ...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: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 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-struct-async.rs:27:74 | 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 + '_ { - | ^^^^^^^^^ + | ----------- ^^^^ + | | | + | | ...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:39:62 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-struct-async.rs:31:74 | 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 + '_ { - | ^^^^^^^^^ + | ----------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: aborting due to 10 previous errors +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-self-async.nll.stderr b/src/test/ui/self/elision/ref-self-async.nll.stderr index ae17ba9839d22..f991f6d9f7fa1 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: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-self-async.rs:34:62 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +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[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:44:57 +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: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-self-async.rs:42:71 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +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[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:56:66 +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: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-self-async.rs:50:73 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +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 `'_` -error: aborting due to 7 previous errors +error: aborting due to 14 previous errors -For more information about this error, try `rustc --explain E0106`. +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/self/elision/ref-self-async.rs b/src/test/ui/self/elision/ref-self-async.rs index 6cca5494ff784..5a5705d7e099b 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 eab77cfacd956..eb796a07a86d5 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. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:32: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. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:38: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/ref-self-async.rs:44: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. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:50: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. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:56: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. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:62: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. - -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 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...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:32:36 +error[E0623]: lifetime mismatch + --> $DIR/ref-self-async.rs:30:48 | 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 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...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:38:45 +error[E0623]: lifetime mismatch + --> $DIR/ref-self-async.rs:34:57 | 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 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...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: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 +error[E0623]: lifetime mismatch + --> $DIR/ref-self-async.rs:38:57 | 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 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...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:50:54 +error[E0623]: lifetime mismatch + --> $DIR/ref-self-async.rs:42:66 | 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 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...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: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 +error[E0623]: lifetime mismatch + --> $DIR/ref-self-async.rs:46:66 | 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 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...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:62:58 +error[E0623]: lifetime mismatch + --> $DIR/ref-self-async.rs:50:69 | 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 + '_ { - | ^^^^^^^^ + | ----- ^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: aborting due to 14 previous errors +error: aborting due to 7 previous errors -For more information about this error, try `rustc --explain E0106`. 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 b4f12d7057db4..437d403e044ed 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: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-struct-async.rs:23:66 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +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[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:33:70 +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: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-struct-async.rs:27:75 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +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[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:39:66 +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: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-struct-async.rs:31:71 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +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 `'_` -error: aborting due to 5 previous errors +error: aborting due to 10 previous errors -For more information about this error, try `rustc --explain E0106`. +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/self/elision/ref-struct-async.rs b/src/test/ui/self/elision/ref-struct-async.rs index cd0f5a2a6058d..f0410bbee906d 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 966e102fa5f27..574b0fddc1eb2 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. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:21: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. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:27: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. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:33: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. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:39: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. - -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 + '_ { - | ^^^^^^^^^ + | ------- ^^^^ + | | | + | | ...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: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 +error[E0623]: lifetime mismatch + --> $DIR/ref-struct-async.rs:19:61 | 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 + '_ { - | ^^^^^^^^^ + | ------- ^^^^ + | | | + | | ...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: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 +error[E0623]: lifetime mismatch + --> $DIR/ref-struct-async.rs:23:61 | 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 + '_ { - | ^^^^^^^^^ + | ------- ^^^^ + | | | + | | ...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: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 +error[E0623]: lifetime mismatch + --> $DIR/ref-struct-async.rs:27:70 | 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 + '_ { - | ^^^^^^^^^ + | ------- ^^^^ + | | | + | | ...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:39:54 +error[E0623]: lifetime mismatch + --> $DIR/ref-struct-async.rs:31:66 | 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 + '_ { - | ^^^^^^^^^ + | ------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: aborting due to 10 previous errors +error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0106`. 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 805d2433f87ac..0000000000000 --- 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 71eba01fe1a02..ec4c3d1522423 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 e3ec1abd44763..0000000000000 --- 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`.