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

Support impl Trait in return type #282

Merged
merged 3 commits into from
Jan 3, 2025
Merged

Support impl Trait in return type #282

merged 3 commits into from
Jan 3, 2025

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Jan 3, 2025

Closes #281.

Without #![feature(impl_trait_in_bindings)]:

    error[E0562]: `impl Trait` is not allowed in paths
        --> tests/test.rs:1680:42
         |
    1680 |         async fn method(&self) -> Result<impl AsRef<str> + Send + Sync, Self::Error> {
         |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = note: `impl Trait` is only allowed in arguments and return types of functions and methods

    error[E0562]: `impl Trait` is not allowed in the type of variable bindings
        --> tests/test.rs:1680:42
         |
    1680 |         async fn method(&self) -> Result<impl AsRef<str> + Send + Sync, Self::Error> {
         |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = note: `impl Trait` is only allowed in arguments and return types of functions and methods
         = note: see issue #63065 <rust-lang/rust#63065> for more information
         = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
         = note: this compiler was built on 2025-01-02; consider upgrading it if it is out of date

With #![feature(impl_trait_in_bindings)]:

    error[E0562]: `impl Trait` is not allowed in paths
        --> tests/test.rs:1680:42
         |
    1680 |         async fn method(&self) -> Result<impl AsRef<str> + Send + Sync, Self::Error> {
         |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = note: `impl Trait` is only allowed in arguments and return types of functions and methods
@dtolnay dtolnay merged commit 1cab7e4 into master Jan 3, 2025
19 checks passed
@dtolnay dtolnay deleted the impltrait branch January 3, 2025 04:25
@dtolnay dtolnay changed the title Support impl Trait in return type Support impl Trait in return type Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cannot implement async trait that returning "impl Trait"
1 participant