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

rust-analyzer shows {unknown} types when it's not clear why it wouldn't be able to #15387

Closed
glandium opened this issue Aug 3, 2023 · 1 comment
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug

Comments

@glandium
Copy link

glandium commented Aug 3, 2023

rust-analyzer version: 0.3.1607-standalone

rustc version: 1.71.0

In the following code:

pub fn foo<T, I: IntoIterator<Item=T>,J: IntoIterator<Item=T>>(i: I, j: J) -> impl Iterator {
    let mut a = i.into_iter();
    let mut b = j.into_iter();

    std::iter::from_fn(move || {
         match (a.next(), b.next()) {
            (Some(a), Some(b)) => Some((a, b)),
            _ => None,
         }
    })
}

Hovering at the end of a.next() shows Option<{unknown}> instead of Option<T>, likewise for b.next(). Hovering a in Some(a) shows {unknown} instead of T, etc.

I thought it could be related to from_fn, but in the following:

pub fn bar<T, I: IntoIterator<Item=T>>(i: I) -> impl Iterator {
    let mut a = i.into_iter();

    std::iter::from_fn(move || {
         match a.next() {
            Some(a) => Some(a),
            _ => None,
         }
    })
}

it works fine.

@glandium glandium added the C-bug Category: bug label Aug 3, 2023
@Veykril Veykril added the A-ty type system / type inference / traits / method resolution label Aug 3, 2023
@flodiebold
Copy link
Member

Duplicate of #10653 (and probably a bunch of others)

@flodiebold flodiebold closed this as not planned Won't fix, can't repro, duplicate, stale Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants