Rollup merge of #68884 - Zoxc:gen-type, r=nikomatsakis
Make the `type_of` return a generic type for generators Fixes https://github.com/rust-lang/rust/issues/67651. r? @nikomatsakis
This commit is contained in:
commit
a1309547f9
19 changed files with 231 additions and 95 deletions
|
@ -139,7 +139,8 @@ fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> BodyAndCache<'_> {
|
|||
let arguments = implicit_argument.into_iter().chain(explicit_arguments);
|
||||
|
||||
let (yield_ty, return_ty) = if body.generator_kind.is_some() {
|
||||
let gen_sig = match ty.kind {
|
||||
let gen_ty = tcx.body_tables(body_id).node_type(id);
|
||||
let gen_sig = match gen_ty.kind {
|
||||
ty::Generator(_, gen_substs, ..) => gen_substs.as_generator().sig(),
|
||||
_ => span_bug!(tcx.hir().span(id), "generator w/o generator type: {:?}", ty),
|
||||
};
|
||||
|
|
|
@ -188,12 +188,12 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
|
|||
Node::Field(field) => icx.to_ty(&field.ty),
|
||||
|
||||
Node::Expr(&Expr { kind: ExprKind::Closure(.., gen), .. }) => {
|
||||
if gen.is_some() {
|
||||
return tcx.typeck_tables_of(def_id).node_type(hir_id);
|
||||
}
|
||||
|
||||
let substs = InternalSubsts::identity_for_item(tcx, def_id);
|
||||
tcx.mk_closure(def_id, substs)
|
||||
if let Some(movability) = gen {
|
||||
tcx.mk_generator(def_id, substs, movability)
|
||||
} else {
|
||||
tcx.mk_closure(def_id, substs)
|
||||
}
|
||||
}
|
||||
|
||||
Node::AnonConst(_) => {
|
||||
|
|
|
@ -18,22 +18,6 @@ LL | | break 0u8;
|
|||
LL | | };
|
||||
| |_________- enclosing `async` block
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/async-block-control-flow-static-semantics.rs:13:43
|
||||
|
|
||||
LL | fn return_targets_async_block_not_fn() -> u8 {
|
||||
| --------------------------------- ^^ expected `u8`, found `()`
|
||||
| |
|
||||
| implicitly returns `()` as its body has no tail or `return` expression
|
||||
|
||||
error[E0271]: type mismatch resolving `<impl std::future::Future as std::future::Future>::Output == ()`
|
||||
--> $DIR/async-block-control-flow-static-semantics.rs:18:39
|
||||
|
|
||||
LL | let _: &dyn Future<Output = ()> = █
|
||||
| ^^^^^^ expected `()`, found `u8`
|
||||
|
|
||||
= note: required for the cast to the object type `dyn std::future::Future<Output = ()>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/async-block-control-flow-static-semantics.rs:22:58
|
||||
|
|
||||
|
@ -55,6 +39,22 @@ LL | let _: &dyn Future<Output = ()> = █
|
|||
|
|
||||
= note: required for the cast to the object type `dyn std::future::Future<Output = ()>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/async-block-control-flow-static-semantics.rs:13:43
|
||||
|
|
||||
LL | fn return_targets_async_block_not_fn() -> u8 {
|
||||
| --------------------------------- ^^ expected `u8`, found `()`
|
||||
| |
|
||||
| implicitly returns `()` as its body has no tail or `return` expression
|
||||
|
||||
error[E0271]: type mismatch resolving `<impl std::future::Future as std::future::Future>::Output == ()`
|
||||
--> $DIR/async-block-control-flow-static-semantics.rs:18:39
|
||||
|
|
||||
LL | let _: &dyn Future<Output = ()> = █
|
||||
| ^^^^^^ expected `()`, found `u8`
|
||||
|
|
||||
= note: required for the cast to the object type `dyn std::future::Future<Output = ()>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/async-block-control-flow-static-semantics.rs:48:44
|
||||
|
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
use std::future::Future;
|
||||
|
||||
fn get_future() -> impl Future<Output = ()> {
|
||||
//~^ ERROR the trait bound `(): std::future::Future` is not satisfied
|
||||
panic!()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,27 @@
|
|||
error[E0277]: the trait bound `(): std::future::Future` is not satisfied
|
||||
--> $DIR/async-error-span.rs:7:20
|
||||
|
|
||||
LL | fn get_future() -> impl Future<Output = ()> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::future::Future` is not implemented for `()`
|
||||
LL |
|
||||
LL | panic!()
|
||||
| -------- this returned value is of type `!`
|
||||
|
|
||||
= note: the return type of a function must have a statically known size
|
||||
|
||||
error[E0698]: type inside `async fn` body must be known in this context
|
||||
--> $DIR/async-error-span.rs:12:9
|
||||
--> $DIR/async-error-span.rs:13:9
|
||||
|
|
||||
LL | let a;
|
||||
| ^ cannot infer type
|
||||
|
|
||||
note: the type is part of the `async fn` body because of this `await`
|
||||
--> $DIR/async-error-span.rs:13:5
|
||||
--> $DIR/async-error-span.rs:14:5
|
||||
|
|
||||
LL | get_future().await;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0698`.
|
||||
Some errors have detailed explanations: E0277, E0698.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
|
|
|
@ -62,6 +62,7 @@ fn foo10() -> Result<(), ()> {
|
|||
fn foo11() -> Result<(), ()> {
|
||||
let _ = await bar()?; //~ ERROR `await` is only allowed inside `async` functions and blocks
|
||||
//~^ ERROR incorrect use of `await`
|
||||
//~| ERROR the `?` operator can only be applied to values that implement `std::ops::Try`
|
||||
Ok(())
|
||||
}
|
||||
fn foo12() -> Result<(), ()> {
|
||||
|
|
|
@ -71,49 +71,49 @@ LL | let _ = await bar()?;
|
|||
| ^^^^^^^^^^^^ help: `await` is a postfix operation: `bar()?.await`
|
||||
|
||||
error: incorrect use of `await`
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:68:14
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:69:14
|
||||
|
|
||||
LL | let _ = (await bar())?;
|
||||
| ^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
|
||||
|
||||
error: incorrect use of `await`
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:73:24
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:74:24
|
||||
|
|
||||
LL | let _ = bar().await();
|
||||
| ^^ help: `await` is not a method call, remove the parentheses
|
||||
|
||||
error: incorrect use of `await`
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:78:24
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:79:24
|
||||
|
|
||||
LL | let _ = bar().await()?;
|
||||
| ^^ help: `await` is not a method call, remove the parentheses
|
||||
|
||||
error: incorrect use of `await`
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:106:13
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:107:13
|
||||
|
|
||||
LL | let _ = await!(bar());
|
||||
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
|
||||
|
||||
error: incorrect use of `await`
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:110:13
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:111:13
|
||||
|
|
||||
LL | let _ = await!(bar())?;
|
||||
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
|
||||
|
||||
error: incorrect use of `await`
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:115:17
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:116:17
|
||||
|
|
||||
LL | let _ = await!(bar())?;
|
||||
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
|
||||
|
||||
error: incorrect use of `await`
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:123:17
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:124:17
|
||||
|
|
||||
LL | let _ = await!(bar())?;
|
||||
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
|
||||
|
||||
error: expected expression, found `=>`
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:131:25
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:132:25
|
||||
|
|
||||
LL | match await { await => () }
|
||||
| ----- ^^ expected expression
|
||||
|
@ -121,13 +121,13 @@ LL | match await { await => () }
|
|||
| while parsing this incorrect await expression
|
||||
|
||||
error: incorrect use of `await`
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:131:11
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:132:11
|
||||
|
|
||||
LL | match await { await => () }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: `await` is a postfix operation: `{ await => () }.await`
|
||||
|
||||
error: expected one of `.`, `?`, `{`, or an operator, found `}`
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:134:1
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:135:1
|
||||
|
|
||||
LL | match await { await => () }
|
||||
| ----- - expected one of `.`, `?`, `{`, or an operator
|
||||
|
@ -162,7 +162,7 @@ LL | let _ = await bar()?;
|
|||
| ^^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:68:14
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:69:14
|
||||
|
|
||||
LL | fn foo12() -> Result<(), ()> {
|
||||
| ----- this is not `async`
|
||||
|
@ -170,7 +170,7 @@ LL | let _ = (await bar())?;
|
|||
| ^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:73:13
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:74:13
|
||||
|
|
||||
LL | fn foo13() -> Result<(), ()> {
|
||||
| ----- this is not `async`
|
||||
|
@ -178,7 +178,7 @@ LL | let _ = bar().await();
|
|||
| ^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:78:13
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:79:13
|
||||
|
|
||||
LL | fn foo14() -> Result<(), ()> {
|
||||
| ----- this is not `async`
|
||||
|
@ -186,7 +186,7 @@ LL | let _ = bar().await()?;
|
|||
| ^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:83:13
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:84:13
|
||||
|
|
||||
LL | fn foo15() -> Result<(), ()> {
|
||||
| ----- this is not `async`
|
||||
|
@ -194,7 +194,7 @@ LL | let _ = bar().await;
|
|||
| ^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:87:13
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:88:13
|
||||
|
|
||||
LL | fn foo16() -> Result<(), ()> {
|
||||
| ----- this is not `async`
|
||||
|
@ -202,7 +202,7 @@ LL | let _ = bar().await?;
|
|||
| ^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:92:17
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:93:17
|
||||
|
|
||||
LL | fn foo() -> Result<(), ()> {
|
||||
| --- this is not `async`
|
||||
|
@ -210,7 +210,7 @@ LL | let _ = bar().await?;
|
|||
| ^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:99:17
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:100:17
|
||||
|
|
||||
LL | let foo = || {
|
||||
| -- this is not `async`
|
||||
|
@ -218,7 +218,7 @@ LL | let _ = bar().await?;
|
|||
| ^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:115:17
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:116:17
|
||||
|
|
||||
LL | fn foo() -> Result<(), ()> {
|
||||
| --- this is not `async`
|
||||
|
@ -226,7 +226,7 @@ LL | let _ = await!(bar())?;
|
|||
| ^^^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:123:17
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:124:17
|
||||
|
|
||||
LL | let foo = || {
|
||||
| -- this is not `async`
|
||||
|
@ -242,7 +242,16 @@ LL | let _ = await bar()?;
|
|||
= help: the trait `std::ops::Try` is not implemented for `impl std::future::Future`
|
||||
= note: required by `std::ops::Try::into_result`
|
||||
|
||||
error: aborting due to 35 previous errors
|
||||
error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:63:19
|
||||
|
|
||||
LL | let _ = await bar()?;
|
||||
| ^^^^^^ the `?` operator cannot be applied to type `impl std::future::Future`
|
||||
|
|
||||
= help: the trait `std::ops::Try` is not implemented for `impl std::future::Future`
|
||||
= note: required by `std::ops::Try::into_result`
|
||||
|
||||
error: aborting due to 36 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0728.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
|
|
20
src/test/ui/async-await/issue-67651.rs
Normal file
20
src/test/ui/async-await/issue-67651.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
// edition:2018
|
||||
|
||||
trait From {
|
||||
fn from();
|
||||
}
|
||||
|
||||
impl From for () {
|
||||
fn from() {}
|
||||
}
|
||||
|
||||
impl From for () {
|
||||
//~^ ERROR conflicting implementations of trait
|
||||
fn from() {}
|
||||
}
|
||||
|
||||
fn bar() -> impl core::future::Future<Output = ()> {
|
||||
async move { From::from() }
|
||||
}
|
||||
|
||||
fn main() {}
|
12
src/test/ui/async-await/issue-67651.stderr
Normal file
12
src/test/ui/async-await/issue-67651.stderr
Normal file
|
@ -0,0 +1,12 @@
|
|||
error[E0119]: conflicting implementations of trait `From` for type `()`:
|
||||
--> $DIR/issue-67651.rs:11:1
|
||||
|
|
||||
LL | impl From for () {
|
||||
| ---------------- first implementation here
|
||||
...
|
||||
LL | impl From for () {
|
||||
| ^^^^^^^^^^^^^^^^ conflicting implementation for `()`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
|
@ -1,13 +0,0 @@
|
|||
error[E0106]: missing lifetime specifier
|
||||
--> $DIR/issue-63388-2.rs:12:10
|
||||
|
|
||||
LL | foo: &dyn Foo, bar: &'a dyn Foo
|
||||
| -------- -----------
|
||||
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`.
|
|
@ -8,7 +8,7 @@ trait Foo {}
|
|||
|
||||
impl Xyz {
|
||||
async fn do_sth<'a>(
|
||||
foo: &dyn Foo, bar: &'a dyn Foo //~ ERROR cannot infer
|
||||
foo: &dyn Foo, bar: &'a dyn Foo
|
||||
) -> &dyn Foo //~ ERROR missing lifetime specifier
|
||||
{
|
||||
foo
|
||||
|
|
|
@ -8,21 +8,6 @@ LL | ) -> &dyn Foo
|
|||
|
|
||||
= 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:11:9
|
||||
|
|
||||
LL | foo: &dyn Foo, bar: &'a dyn Foo
|
||||
| ^^^ ...but this borrow...
|
||||
...
|
||||
LL | foo
|
||||
| --- this return type evaluates to the `'static` lifetime...
|
||||
|
|
||||
note: ...can't outlive the lifetime `'_` as defined on the method body at 11:14
|
||||
--> $DIR/issue-63388-2.rs:11:14
|
||||
|
|
||||
LL | foo: &dyn Foo, bar: &'a dyn Foo
|
||||
| ^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
async fn copy() -> Result<()> //~ ERROR wrong number of type arguments
|
||||
{
|
||||
Ok(())
|
||||
//~^ type annotations needed
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
|
@ -4,6 +4,13 @@ error[E0107]: wrong number of type arguments: expected 2, found 1
|
|||
LL | async fn copy() -> Result<()>
|
||||
| ^^^^^^^^^^ expected 2 type arguments
|
||||
|
||||
error: aborting due to previous error
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/issue-65159.rs:7:5
|
||||
|
|
||||
LL | Ok(())
|
||||
| ^^ cannot infer type for type parameter `E` declared on the enum `Result`
|
||||
|
||||
For more information about this error, try `rustc --explain E0107`.
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0107, E0282.
|
||||
For more information about an error, try `rustc --explain E0107`.
|
||||
|
|
|
@ -9,6 +9,9 @@ impl<T> Trait<'_, '_> for T { }
|
|||
async fn async_ret_impl_trait<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a, 'b> {
|
||||
//~^ ERROR ambiguous lifetime bound
|
||||
//~| ERROR ambiguous lifetime bound
|
||||
//~| ERROR ambiguous lifetime bound
|
||||
//~| ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
//~| ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
(a, b)
|
||||
}
|
||||
|
||||
|
|
|
@ -14,5 +14,42 @@ LL | async fn async_ret_impl_trait<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'
|
|||
|
|
||||
= help: add #![feature(member_constraints)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: ambiguous lifetime bound in `impl Trait`
|
||||
--> $DIR/ret-impl-trait-no-fg.rs:9:64
|
||||
|
|
||||
LL | async fn async_ret_impl_trait<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a, 'b> {
|
||||
| ^^^^^^^^^^^^^^^^^^ the elided lifetimes here do not outlive one another
|
||||
|
|
||||
= help: add #![feature(member_constraints)] to the crate attributes to enable
|
||||
|
||||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
--> $DIR/ret-impl-trait-no-fg.rs:9:1
|
||||
|
|
||||
LL | / async fn async_ret_impl_trait<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a, 'b> {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | (a, b)
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
||||
= note: hidden type `(&u8, &u8)` captures lifetime '_#4r
|
||||
|
||||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
--> $DIR/ret-impl-trait-no-fg.rs:9:1
|
||||
|
|
||||
LL | / async fn async_ret_impl_trait<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a, 'b> {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | (a, b)
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
||||
= note: hidden type `(&u8, &u8)` captures lifetime '_#5r
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0700`.
|
||||
|
|
|
@ -1,13 +1,72 @@
|
|||
error[E0658]: `Wrap<&Struct, Struct>` cannot be used as the type of `self` without the `arbitrary_self_types` feature
|
||||
--> $DIR/ref-self-async.rs:47:39
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ref-self-async.rs:23:9
|
||||
|
|
||||
LL | async fn ref_self(&self, f: &u32) -> &u32 {
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ref-self-async.rs:29:9
|
||||
|
|
||||
LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 {
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ref-self-async.rs:33:9
|
||||
|
|
||||
LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ref-self-async.rs:37:9
|
||||
|
|
||||
LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ref-self-async.rs:41:9
|
||||
|
|
||||
LL | async fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ref-self-async.rs:45:9
|
||||
|
|
||||
LL | async fn box_pin_ref_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ref-self-async.rs:49:9
|
||||
|
|
||||
LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information
|
||||
= help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | f
|
||||
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||
|
||||
error: aborting due to previous error
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// edition:2018
|
||||
|
||||
#![allow(non_snake_case)]
|
||||
#![feature(arbitrary_self_types)]
|
||||
|
||||
use std::marker::PhantomData;
|
||||
use std::ops::Deref;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-self-async.rs:22:9
|
||||
--> $DIR/ref-self-async.rs:23:9
|
||||
|
|
||||
LL | async fn ref_self(&self, f: &u32) -> &u32 {
|
||||
| ----- ----
|
||||
|
@ -9,7 +9,7 @@ LL | f
|
|||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-self-async.rs:28:9
|
||||
--> $DIR/ref-self-async.rs:29:9
|
||||
|
|
||||
LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 {
|
||||
| ----- ----
|
||||
|
@ -19,7 +19,7 @@ LL | f
|
|||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-self-async.rs:32:9
|
||||
--> $DIR/ref-self-async.rs:33:9
|
||||
|
|
||||
LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
|
||||
| ----- ----
|
||||
|
@ -29,7 +29,7 @@ LL | f
|
|||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-self-async.rs:36:9
|
||||
--> $DIR/ref-self-async.rs:37:9
|
||||
|
|
||||
LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
|
||||
| ----- ----
|
||||
|
@ -39,7 +39,7 @@ LL | f
|
|||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-self-async.rs:40:9
|
||||
--> $DIR/ref-self-async.rs:41:9
|
||||
|
|
||||
LL | async fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
|
||||
| ----- ----
|
||||
|
@ -49,7 +49,7 @@ LL | f
|
|||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-self-async.rs:44:9
|
||||
--> $DIR/ref-self-async.rs:45:9
|
||||
|
|
||||
LL | async fn box_pin_ref_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
|
||||
| ----- ----
|
||||
|
@ -59,7 +59,7 @@ LL | f
|
|||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-self-async.rs:48:9
|
||||
--> $DIR/ref-self-async.rs:49:9
|
||||
|
|
||||
LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 {
|
||||
| ----- ---
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue