Skip to content

Rollup of 6 pull requests #103685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
328f817
Make `CStr::from_ptr` `const`.
reitermarkus Oct 12, 2022
36dbb07
Update docs for `CStr::from_ptr`.
reitermarkus Oct 12, 2022
4accf83
Note scope of TAIT more accurately
compiler-errors Oct 22, 2022
8b984e5
fake capture if min_captures empty
ouz-a Aug 11, 2022
e521a8d
Prevent foreign Rust exceptions from being caught
nbdd0121 Oct 5, 2022
86c65d2
Implement Rust foreign exception protection for EMCC and SEH
nbdd0121 Oct 5, 2022
daf3063
Add test case for foreign Rust exceptions
nbdd0121 Oct 5, 2022
979d1a2
Apply suggestion
nbdd0121 Oct 11, 2022
4e6d60c
Fix alloc size
nbdd0121 Oct 12, 2022
c9cca33
Fix windows compilation
nbdd0121 Oct 23, 2022
8b494f4
Allow `impl Fn() -> impl Trait` in return position
WaffleLapkin Feb 2, 2022
7a4ba2f
Add more tests for `impl Fn() -> impl Trait`
WaffleLapkin Jun 23, 2022
00f2277
Add even more tests for `impl Fn() -> impl Trait`
WaffleLapkin Jun 23, 2022
cc752f5
Feature gate `impl_trait_in_fn_trait_return`
WaffleLapkin Jul 24, 2022
d116859
--bless
WaffleLapkin Jul 28, 2022
690e037
add a test for gate `impl_trait_in_fn_trait_return`
WaffleLapkin Jul 28, 2022
e93982a
adopt to compiler changes
WaffleLapkin Oct 25, 2022
bfac2da
Ignore test on mingw32
nbdd0121 Oct 26, 2022
92b314b
add test for issue 98634
Rageking8 Oct 21, 2022
b3f9277
Remove unneeded attribute.
reitermarkus Oct 28, 2022
38abbcf
Rollup merge of #93582 - WaffleLapkin:rpitirpit, r=compiler-errors
Dylan-DPC Oct 28, 2022
eb6cd05
Rollup merge of #100452 - ouz-a:issue-93242, r=jackh726
Dylan-DPC Oct 28, 2022
28ece5a
Rollup merge of #102721 - nbdd0121:panic, r=Amanieu
Dylan-DPC Oct 28, 2022
6db281a
Rollup merge of #102961 - reitermarkus:const-cstr-from-ptr, r=oli-obk
Dylan-DPC Oct 28, 2022
ccc10a4
Rollup merge of #103342 - Rageking8:add-test-for-issue-98634, r=compi…
Dylan-DPC Oct 28, 2022
e7fb356
Rollup merge of #103383 - compiler-errors:tait-scope, r=oli-obk
Dylan-DPC Oct 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add test for issue 98634
  • Loading branch information
Rageking8 committed Oct 28, 2022
commit 92b314ba30c396fab7e4ffeabf3ebf3f6101516a
50 changes: 50 additions & 0 deletions src/test/ui/async-await/issue-98634.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// edition: 2021

use std::{
future::Future,
pin::Pin,
task::{Context, Poll, Waker},
};

pub struct StructAsync<F: Fn() -> Pin<Box<dyn Future<Output = ()>>>> {
pub callback: F,
}

impl<F> Future for StructAsync<F>
where
F: Fn() -> Pin<Box<dyn Future<Output = ()>>>,
{
type Output = ();

fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Self::Output> {
Poll::Pending
}
}

async fn callback() {}

struct Runtime;

fn waker() -> &'static Waker {
todo!()
}

impl Runtime {
#[track_caller]
pub fn block_on<F: Future>(&self, mut future: F) -> F::Output {
loop {
unsafe {
Pin::new_unchecked(&mut future).poll(&mut Context::from_waker(waker()));
}
}
}
}

fn main() {
Runtime.block_on(async {
StructAsync { callback }.await;
//~^ ERROR expected `fn() -> impl Future<Output = ()> {callback}` to be a fn item that returns `Pin<Box<(dyn Future<Output = ()> + 'static)>>`, but it returns `impl Future<Output = ()>`
//~| ERROR expected `fn() -> impl Future<Output = ()> {callback}` to be a fn item that returns `Pin<Box<(dyn Future<Output = ()> + 'static)>>`, but it returns `impl Future<Output = ()>`
//~| ERROR expected `fn() -> impl Future<Output = ()> {callback}` to be a fn item that returns `Pin<Box<(dyn Future<Output = ()> + 'static)>>`, but it returns `impl Future<Output = ()>`
});
}
60 changes: 60 additions & 0 deletions src/test/ui/async-await/issue-98634.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
error[E0271]: expected `fn() -> impl Future<Output = ()> {callback}` to be a fn item that returns `Pin<Box<(dyn Future<Output = ()> + 'static)>>`, but it returns `impl Future<Output = ()>`
--> $DIR/issue-98634.rs:45:23
|
LL | StructAsync { callback }.await;
| ^^^^^^^^ expected struct `Pin`, found opaque type
|
note: while checking the return type of the `async fn`
--> $DIR/issue-98634.rs:24:21
|
LL | async fn callback() {}
| ^ checked the `Output` of this `async fn`, found opaque type
= note: expected struct `Pin<Box<(dyn Future<Output = ()> + 'static)>>`
found opaque type `impl Future<Output = ()>`
note: required by a bound in `StructAsync`
--> $DIR/issue-98634.rs:9:35
|
LL | pub struct StructAsync<F: Fn() -> Pin<Box<dyn Future<Output = ()>>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StructAsync`

error[E0271]: expected `fn() -> impl Future<Output = ()> {callback}` to be a fn item that returns `Pin<Box<(dyn Future<Output = ()> + 'static)>>`, but it returns `impl Future<Output = ()>`
--> $DIR/issue-98634.rs:45:9
|
LL | StructAsync { callback }.await;
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Pin`, found opaque type
|
note: while checking the return type of the `async fn`
--> $DIR/issue-98634.rs:24:21
|
LL | async fn callback() {}
| ^ checked the `Output` of this `async fn`, found opaque type
= note: expected struct `Pin<Box<(dyn Future<Output = ()> + 'static)>>`
found opaque type `impl Future<Output = ()>`
note: required by a bound in `StructAsync`
--> $DIR/issue-98634.rs:9:35
|
LL | pub struct StructAsync<F: Fn() -> Pin<Box<dyn Future<Output = ()>>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StructAsync`

error[E0271]: expected `fn() -> impl Future<Output = ()> {callback}` to be a fn item that returns `Pin<Box<(dyn Future<Output = ()> + 'static)>>`, but it returns `impl Future<Output = ()>`
--> $DIR/issue-98634.rs:45:33
|
LL | StructAsync { callback }.await;
| ^^^^^^ expected struct `Pin`, found opaque type
|
note: while checking the return type of the `async fn`
--> $DIR/issue-98634.rs:24:21
|
LL | async fn callback() {}
| ^ checked the `Output` of this `async fn`, found opaque type
= note: expected struct `Pin<Box<(dyn Future<Output = ()> + 'static)>>`
found opaque type `impl Future<Output = ()>`
note: required by a bound in `StructAsync`
--> $DIR/issue-98634.rs:9:35
|
LL | pub struct StructAsync<F: Fn() -> Pin<Box<dyn Future<Output = ()>>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StructAsync`

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0271`.