Skip to content

False-positive type-mismatch error with generic future #12441

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
aidanalphafund opened this issue Jun 1, 2022 · 0 comments
Closed

False-positive type-mismatch error with generic future #12441

aidanalphafund opened this issue Jun 1, 2022 · 0 comments
Labels
A-diagnostics diagnostics / error reporting A-ty type system / type inference / traits / method resolution C-bug Category: bug

Comments

@aidanalphafund
Copy link

Description

It seems rust analyzer can't resolve the output type of a future if that output is generic on another future's output type, leading to erroneous type-mismatch errors.

I initially ran into this using try_for_each_concurrent on a stream, but managed to narrow the problem to a much simpler reproduction.

Reproduction (playground)

use std::future::Future;

async fn reproduction() -> usize {
    MyFut(async { 3 }).await
}

struct MyFut<Fut>(Fut);

impl<Fut: Future> Future for MyFut<Fut> {
    type Output = Fut::Output;

    fn poll(
        self: std::pin::Pin<&mut Self>,
        cx: &mut std::task::Context<'_>,
    ) -> std::task::Poll<Self::Output> {
        todo!()
    }
}

rust-analyzer version: f94fa62 2022-05-30 stable
rustc version: rustc 1.61.0 (fe5b13d68 2022-05-18)

@jonas-schievink jonas-schievink added A-ty type system / type inference / traits / method resolution A-diagnostics diagnostics / error reporting C-bug Category: bug labels Jun 1, 2022
bitgaoshu added a commit to bitgaoshu/rust-analyzer that referenced this issue Jun 3, 2022
bitgaoshu added a commit to bitgaoshu/rust-analyzer that referenced this issue Jun 3, 2022
bors added a commit that referenced this issue Jun 12, 2022
fix: #12441 False-positive type-mismatch error with generic future

I think the reason is same with #11815.
add ```Sized``` bound for ```AsyncBlockTypeImplTrait```.
@bors bors closed this as completed in 1a97ab3 Jun 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics diagnostics / error reporting A-ty type system / type inference / traits / method resolution C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants