Skip to content

default-body async fn in trait with impl Trait return fails to compile #102688

New issue

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

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

Already on GitHub? # to your account

Closed
compiler-errors opened this issue Oct 5, 2022 · 1 comment · Fixed by #103355
Closed

default-body async fn in trait with impl Trait return fails to compile #102688

compiler-errors opened this issue Oct 5, 2022 · 1 comment · Fixed by #103355
Assignees
Labels
C-bug Category: This is a bug. F-async_fn_in_trait Static async fn in traits F-return_position_impl_trait_in_trait `#![feature(return_position_impl_trait_in_trait)]` requires-nightly This issue requires a nightly compiler in some way.

Comments

@compiler-errors
Copy link
Member

compiler-errors commented Oct 5, 2022

This code fails to compile after #101679:

#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]

use std::fmt::Debug;

trait Foo {
    async fn baz(&self) -> impl Debug {
        ""
    }
}

struct Bar;

impl Foo for Bar {}

fn main() {
    let _ = Bar.baz();
}

This is the same RPIT issue as #101968 (comment). Filing as a known-bug.

@compiler-errors compiler-errors added C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. F-async_fn_in_trait Static async fn in traits F-return_position_impl_trait_in_trait `#![feature(return_position_impl_trait_in_trait)]` labels Oct 5, 2022
@compiler-errors compiler-errors self-assigned this Oct 5, 2022
@compiler-errors
Copy link
Member Author

I have a hacky solution to fix this and to fix #101968 (comment), but it's disgusting, so I want to separate it from #101679.

notriddle added a commit to notriddle/rust that referenced this issue Oct 22, 2022
…ck, r=oli-obk

Handle return-position `impl Trait` in traits properly in `register_hidden_type`

The bounds that we get by calling `bound_explicit_item_bounds` from an RPITIT have projections, not opaques, but when we're *registering* an opaque, we want to treat it like an opaque.

Coincidentally fixes rust-lang#102688 as well, which makes sense, since that was failing because we were inferring an opaque type to be equal to itself (opaque cycle error => "cannot resolve opaque type").

Fixes rust-lang#103352

r? `@oli-obk`
notriddle added a commit to notriddle/rust that referenced this issue Oct 22, 2022
…ck, r=oli-obk

Handle return-position `impl Trait` in traits properly in `register_hidden_type`

The bounds that we get by calling `bound_explicit_item_bounds` from an RPITIT have projections, not opaques, but when we're *registering* an opaque, we want to treat it like an opaque.

Coincidentally fixes rust-lang#102688 as well, which makes sense, since that was failing because we were inferring an opaque type to be equal to itself (opaque cycle error => "cannot resolve opaque type").

Fixes rust-lang#103352

r? ``@oli-obk``
@bors bors closed this as completed in ff689a1 Oct 23, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. F-async_fn_in_trait Static async fn in traits F-return_position_impl_trait_in_trait `#![feature(return_position_impl_trait_in_trait)]` requires-nightly This issue requires a nightly compiler in some way.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant