Skip to content

False positive for infinite_iter #3538

@michael-p

Description

@michael-p

The following code causes clippy to trigger the infinite_iter lint but it's perfectly fine since ArrayVec only takes a limited amount (10 in this case) of items from the iterator (see ArrayVec documentation

use arrayvec::ArrayVec;
use std::iter;

fn main() {
    let stuff: ArrayVec<[u8; 10]> = iter::repeat(22).collect();
    println!("{:?}", stuff); // -> [22, 22, 22, 22, 22, 22, 22, 22, 22, 22]
}

Note that infinite_iter is set to deny by default, causing compilation to abort with an error.

Clippy version: clippy 0.0.212 (2e26fdc2 2018-11-22)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions