rust-lang/rust-clippy

`never_loop`: Note why the loop will never loop.

クローズ

#16,056 opened on 2025/11/09

 (7 件のコメント) (0 件のリアクション) (1 人の担当者)Rust (1,391 件のフォーク)batch import
C-enhancementgood first issue

Repository metrics

Stars
 (10,406 個のスター)
PR merge metrics
 (平均マージ 19d 22h) (30d で 113 merged PRs)

説明

Description

The reason why a loop will never actually complete isn't always obvious (see #16054 for an example). For such cases it would be nice to have a note pointing out all the locations where this occurs. Obvious causes ideally wouldn't get any additional output.

Examples

loop {
    do_something();
    // No need to point this out.
    panic!();
}
// Imagine something less obvious.
let x = || Some(panic!());

loop {
    // Why doesn't this loop?
    x().unwrap();
}

Version

Additional Labels

No response

コントリビューターガイド