Skip to content
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

async fn in trait should require async fn in impl #102745

Closed
compiler-errors opened this issue Oct 6, 2022 · 6 comments · Fixed by #104592
Closed

async fn in trait should require async fn in impl #102745

compiler-errors opened this issue Oct 6, 2022 · 6 comments · Fixed by #104592
Assignees
Labels
F-async_fn_in_trait Static async fn in traits

Comments

@compiler-errors
Copy link
Member

compiler-errors commented Oct 6, 2022

For now, we've decided that an async fn() -> T in a trait should not be satisfied by a fn() -> Type where Type: Future<Output = T> until we at least hammer out how #[refine] is gonna work, etc.

So let's just do a HIR check that the signatures are compatible.

@compiler-errors
Copy link
Member Author

Assigning to @ComputerDruid who expressed interest in working on this.

@compiler-errors
Copy link
Member Author

@rustbot assign @ComputerDruid

idk if that works, the github UI doesn't let me assign to you 😝

@rustbot rustbot self-assigned this Oct 6, 2022
@compiler-errors
Copy link
Member Author

ugh lol

@compiler-errors compiler-errors added the F-async_fn_in_trait Static async fn in traits label Oct 6, 2022
@ComputerDruid
Copy link
Contributor

@rustbot claim

@rustbot rustbot assigned ComputerDruid and unassigned rustbot Oct 6, 2022
@zirconium-n
Copy link
Contributor

Should it be satisfied with fn() -> impl Future<Output = T> ?

@compiler-errors
Copy link
Member Author

I think not for now, and certainly not without the user enabling the return_position_impl_trait_in_trait feature gate

matthiaskrgr pushed a commit to matthiaskrgr/rust that referenced this issue Oct 28, 2022
- Add comment to some tests that will break when rust-lang#102745 is implemented
- Mark a test with known-bug
- Delete duplicate test
ComputerDruid added a commit to ComputerDruid/rust that referenced this issue Dec 9, 2022
As a workaround for the full `#[refine]` semantics not being implemented
yet, forbit returning a concrete future type like `Box<dyn Future>` or a
manually implemented Future.

`-> impl Future` is still permitted; while that can also cause
accidental refinement, that's behind a different feature gate
(`return_position_impl_trait_in_trait`) and that problem exists
regardless of whether the trait method is async, so will have to be
solved more generally.

Fixes rust-lang#102745
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 14, 2022
…ler-errors

Ensure async trait impls are async (or otherwise return an opaque type)

As a workaround for the full `#[refine]` semantics not being implemented
yet, forbit returning a concrete future type like `Box<dyn Future>` or a
manually implemented Future.

`-> impl Future` is still permitted; while that can also cause
accidental refinement, that's behind a different feature gate
(`return_position_impl_trait_in_trait`) and that problem exists
regardless of whether the trait method is async, so will have to be
solved more generally.

Fixes rust-lang#102745
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 15, 2022
…ler-errors

Ensure async trait impls are async (or otherwise return an opaque type)

As a workaround for the full `#[refine]` semantics not being implemented
yet, forbit returning a concrete future type like `Box<dyn Future>` or a
manually implemented Future.

`-> impl Future` is still permitted; while that can also cause
accidental refinement, that's behind a different feature gate
(`return_position_impl_trait_in_trait`) and that problem exists
regardless of whether the trait method is async, so will have to be
solved more generally.

Fixes rust-lang#102745
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 15, 2022
…ler-errors

Ensure async trait impls are async (or otherwise return an opaque type)

As a workaround for the full `#[refine]` semantics not being implemented
yet, forbit returning a concrete future type like `Box<dyn Future>` or a
manually implemented Future.

`-> impl Future` is still permitted; while that can also cause
accidental refinement, that's behind a different feature gate
(`return_position_impl_trait_in_trait`) and that problem exists
regardless of whether the trait method is async, so will have to be
solved more generally.

Fixes rust-lang#102745
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 15, 2022
…ler-errors

Ensure async trait impls are async (or otherwise return an opaque type)

As a workaround for the full `#[refine]` semantics not being implemented
yet, forbit returning a concrete future type like `Box<dyn Future>` or a
manually implemented Future.

`-> impl Future` is still permitted; while that can also cause
accidental refinement, that's behind a different feature gate
(`return_position_impl_trait_in_trait`) and that problem exists
regardless of whether the trait method is async, so will have to be
solved more generally.

Fixes rust-lang#102745
@bors bors closed this as completed in da98ef9 Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-async_fn_in_trait Static async fn in traits
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants