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

Unable to resolve traits correctly in fns with two IntoIterator type parameters #16878

Closed
tetrogem opened this issue Mar 18, 2024 · 3 comments
Closed
Labels
C-bug Category: bug

Comments

@tetrogem
Copy link

tetrogem commented Mar 18, 2024

rust-analyzer version: 0.3.1885-standalone (b6d1887 2024-03-17)

rustc version: rustc 1.76.0 (07dca489a 2024-02-04)

relevant settings: n/a

repository link (if public, optional): n/a

code snippet to reproduce:

// example trait to reproduce
pub trait Map {
    fn map(&self, x: u32, y: u32) -> Self;
}

impl Map for u32 {
    fn map(&self, x: u32, _y: u32) -> Self {
        x
    }
}

fn main() {
    one_into_iter([1]);
    two_iterators([1].iter(), [1.].iter());
    two_into_iters([1], [1.]);
}

fn one_into_iter(_a: impl IntoIterator<Item = u32>) -> u32 {
    0.map(1, 2) // resolves correctly with one IntoIterator...
}

fn two_iterators<A: Iterator<Item = u32>, B: Iterator<Item = f64>>(_a: A, _b: B) -> u32 {
    0.map(1, 2) // resolves correctly with two Iterators...
}

fn two_into_iters<A: IntoIterator<Item = u32>, B: IntoIterator<Item = f64>>(_a: A, _b: B) -> u32 {
    0.map(1, 2) // with two IntoIterators, doesn't resolve to correct method -- errors...
    // (expected 1 argument, found 2) -- resolving it as Iterator::map, not Map::map
}

This only happens if there are two type parameters which are both IntoIterator as far as I've seen, having one IntoIterator or 2+ type parameters of other types both work fine, it's just IntoIterator

@tetrogem tetrogem added the C-bug Category: bug label Mar 18, 2024
@ShoyuVanilla
Copy link
Member

Might be related to trait bounds with associated types. I'll check this few hours later.

@lnicola
Copy link
Member

lnicola commented Mar 19, 2024

Duplicate of #10653.

@lnicola lnicola closed this as completed Mar 19, 2024
@ShoyuVanilla
Copy link
Member

It's sad that the original issue is unactionable 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants