rust-lang/rust-clippy

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

已關閉

#16,056 建立於 2025年11月9日

 (7 則留言) (0 個反應) (1 位負責人)Rust (1,391 個分叉)batch import
C-enhancementgood first issue

倉庫指標

星標
 (10,406 顆星)
PR 合併指標
 (平均合併 19天 22小時) (30 天內合併 113 個 PR)

描述

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

貢獻者指南