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

RFC: Return-position impl Trait in trait #291

Closed
Tracked by #279
tmandry opened this issue Mar 7, 2023 · 3 comments
Closed
Tracked by #279

RFC: Return-position impl Trait in trait #291

tmandry opened this issue Mar 7, 2023 · 3 comments
Assignees
Milestone

Comments

@tmandry
Copy link
Member

tmandry commented Mar 7, 2023

This is a roadmap item for wg-async. You can view the roadmap here: https://github.com/orgs/rust-lang/projects/28

Allow -> impl Trait methods in traits, e.g.

trait Iterable {
    fn iter(&self) -> impl Iterator;
}

Open questions

Semver hazard caused by auto trait leakage

Auto traits leak from public functions using async fn and return-position impl Trait. This is a pre-existing issue.

Once we make these features available within traits we have a chance to proactively make sure crate authors don't accidentally stabilize auto traits. For example, we could make it a lint or a hard error if you have a publicly-accessible function that is not explicit about its auto traits.

It's obvious how to do this for -> impl Trait (add + Send and probably #[refine]), but not async fn. We could also punt on this and make it a lint for all uses of -> impl Trait later (not only inside traits), upgrading to a hard error over an edition.

@tmandry tmandry self-assigned this Mar 7, 2023
@tmandry tmandry added this to the Async 2023 milestone Mar 7, 2023
@tmandry tmandry added the roadmap-topic Top-line goal for the roadmap label Mar 7, 2023
@Noah-Kennedy

This comment was marked as outdated.

@tmandry tmandry removed the roadmap-topic Top-line goal for the roadmap label Mar 9, 2023
@tmandry
Copy link
Member Author

tmandry commented Apr 28, 2023

RFC is up: rust-lang/rfcs#3425

@tmandry
Copy link
Member Author

tmandry commented Jul 7, 2023

RFC was merged. Tracking issue: rust-lang/rust#91611

@tmandry tmandry closed this as completed Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants