Skip to content

Itertools::max is misdetected as Ord::max, resulting in expected 1 argument, found 0 error #10673

Closed
@TonalidadeHidrica

Description

@TonalidadeHidrica

Steps to reproduce

Create a new bin crate, and replace src/main.rs with the following code.

src/main.rs

fn main() {
    let _ = vec![vec![1, 2, 3]]
        .iter()
        .flat_map(|x| x.iter().flat_map(|x| Some(x)))
        .max()
        .unwrap();
}

When edition = "2021", nothing is wrong.
When edition = "2018", rust-analyzer points out that there is an error on the fifth line (.max()): [rust-analyzer mismatched-arg-count] [E] expected 1 argument, found 0.
Hovering on the max shows core::cmp::Ord, not std::iter::Iterator.

In both case, cargo check shows no errors or warnings.

Probably there is an issue in resolving traits in prelude.

Version info

rustup show

active toolchain
----------------

stable-x86_64-apple-darwin (default)
rustc 1.56.0 (09c42c458 2021-10-18)

:CocInfo

## versions

vim version: NVIM v0.6.0-dev+nightly-756-g8c74c895b
node version: v14.18.1
coc.nvim version: 0.0.80-03c9add7cd
coc.nvim directory: /Users/username/.vim/dein/.cache/init.vim/.dein
term: tmux
platform: darwin

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tytype system / type inference / traits / method resolutionC-bugCategory: bugS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions