forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split out async_fn_in_trait into a separate feature
PR rust-lang#101224 added support for async fn in trait desuraging behind the return_position_impl_trait_in_trait feature. Split this out so that it's behind its own feature gate, since async fn in trait doesn't need to follow the same stabilization schedule.
- Loading branch information
1 parent
9062b78
commit d0a0749
Showing
13 changed files
with
133 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// edition:2021 | ||
|
||
// RPITIT is not enough to allow use of async functions | ||
#![allow(incomplete_features)] | ||
#![feature(return_position_impl_trait_in_trait)] | ||
|
||
trait T { | ||
async fn foo(); //~ ERROR functions in traits cannot be declared `async` | ||
} | ||
|
||
// Both return_position_impl_trait_in_trait and async_fn_in_trait are required for this (see also | ||
// feature-gate-return_position_impl_trait_in_trait.rs) | ||
trait T2 { | ||
async fn foo() -> impl Sized; //~ ERROR functions in traits cannot be declared `async` | ||
} | ||
|
||
trait T3 { | ||
fn foo() -> impl std::future::Future<Output = ()>; | ||
} | ||
|
||
impl T3 for () { | ||
async fn foo() {} //~ ERROR functions in traits cannot be declared `async` | ||
} | ||
|
||
fn main() {} |
42 changes: 42 additions & 0 deletions
42
src/test/ui/async-await/feature-gate-async_fn_in_trait.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
error[E0706]: functions in traits cannot be declared `async` | ||
--> $DIR/feature-gate-async_fn_in_trait.rs:8:5 | ||
| | ||
LL | async fn foo(); | ||
| -----^^^^^^^^^^ | ||
| | | ||
| `async` because of this | ||
| | ||
= note: `async` trait functions are not currently supported | ||
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait | ||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information | ||
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable | ||
|
||
error[E0706]: functions in traits cannot be declared `async` | ||
--> $DIR/feature-gate-async_fn_in_trait.rs:14:5 | ||
| | ||
LL | async fn foo() -> impl Sized; | ||
| -----^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| `async` because of this | ||
| | ||
= note: `async` trait functions are not currently supported | ||
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait | ||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information | ||
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable | ||
|
||
error[E0706]: functions in traits cannot be declared `async` | ||
--> $DIR/feature-gate-async_fn_in_trait.rs:22:5 | ||
| | ||
LL | async fn foo() {} | ||
| -----^^^^^^^^^ | ||
| | | ||
| `async` because of this | ||
| | ||
= note: `async` trait functions are not currently supported | ||
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait | ||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information | ||
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0706`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
// edition:2021 | ||
|
||
// async_fn_in_trait is not enough to allow use of RPITIT | ||
#![allow(incomplete_features)] | ||
#![feature(async_fn_in_trait)] | ||
|
||
trait Foo { | ||
fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return | ||
fn baz() -> Box<impl std::fmt::Display>; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return | ||
} | ||
|
||
// Both return_position_impl_trait_in_trait and async_fn_in_trait are required for this (see also | ||
// feature-gate-async_fn_in_trait.rs) | ||
trait AsyncFoo { | ||
async fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return | ||
} | ||
|
||
fn main() {} |
22 changes: 20 additions & 2 deletions
22
src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return | ||
--> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:2:17 | ||
--> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:8:17 | ||
| | ||
LL | fn bar() -> impl Sized; | ||
| ^^^^^^^^^^ | ||
| | ||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information | ||
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable | ||
|
||
error: aborting due to previous error | ||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return | ||
--> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:9:21 | ||
| | ||
LL | fn baz() -> Box<impl std::fmt::Display>; | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information | ||
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable | ||
|
||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return | ||
--> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:15:23 | ||
| | ||
LL | async fn bar() -> impl Sized; | ||
| ^^^^^^^^^^ | ||
| | ||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information | ||
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0562`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters