Skip to content

Autocomplete/hover broken in IndexMap with tuple key #14871

Closed
@jprochazk

Description

@jprochazk
Contributor

When hovering over retain in the following snippet, rust-analyzer does not display any tooltip.

use indexmap::IndexMap; // 1.9.3

fn main() {
    let mut map = IndexMap::<(usize, usize), usize>::new();
    map.retain(|_, _| true);
}

If the key is changed to just usize, it starts working again:

use indexmap::IndexMap; // 1.9.3

fn main() {
    let mut map = IndexMap::<usize, usize>::new();
    map.retain(|_, _| true);
}

std::collections::HashMap doesn't seem to have the same issue.

rust-analyzer version: rust-analyzer version: 0.3.1524-standalone

rustc version: rustc 1.71.0-nightly (77f4f828a 2023-05-20)

relevant settings: -

Activity

lowr

lowr commented on May 22, 2023

@lowr
Contributor

This is... not nice. We're now failing to prove some basic trait references for tuples because they are implemented by this macro, which contains ${count(x)} metavariable expression on nightly that we haven't implemented yet (#11952). It was introduced in rust-lang/rust@4d04a06 as part of rust-lang/rust#97594.

In particular, we're failing to prove (usize, usize): PartialEq that's required by IndexMap::retain().

We have two options: implement ${count(x)} asap (before it lands on stable at the very least) or file a PR to revert that commit. I'll look into it in the coming days.

added
A-macromacro expansion
Broken WindowBugs / technical debt to be addressed immediately
on May 22, 2023
added a commit that references this issue on May 28, 2023

Auto merge of #14878 - lowr:feat/metavar-expr-count, r=Veykril

150082b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macromacro expansionBroken WindowBugs / technical debt to be addressed immediatelyC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @jprochazk@lowr

      Issue actions

        Autocomplete/hover broken in IndexMap with tuple key · Issue #14871 · rust-lang/rust-analyzer