rust-lang/rust-clippy

New lint: `while let Some(&x) = slice.iter().next()` is infinite loop

Open

#4,554 建立於 2019年9月19日

在 GitHub 查看
 (12 留言) (0 反應) (1 負責人)Rust (10,406 star) (1,391 fork)batch import
A-lintL-correctnessL-suggestiongood first issue

描述

This code is an infinite loop: (Do not run this in playpen)

fn main() {
    let a = [1, 2, 3];
    while let Some(&x) = a.iter().next() {
        println!("{:?}", x);
    }
}

貢獻者指南

New lint: `while let Some(&x) = slice.iter().next()` is infinite loop · rust-lang/rust-clippy#4554 | Good First Issue