-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing
Description
Summary
In order to suppress the needless_continue warning the corresponding allow attribute must be placed on entire function. I'm not sure if it is easy (or possible) to fix, but ideally the attribute can be placed on the continue expression itself. Please see the example.
Reproducer
Code:
#![warn(clippy::pedantic)]
fn some_condition() -> bool { true }
fn another_condition() -> bool { true }
fn main() {
for _ in 0..5 {
if some_condition() {
// ...
continue;
}
if another_condition() {
// ...
#[allow(clippy::needless_continue)]
continue;
}
}
}Current output:
warning: this
continueexpression is redundant
Desired output:
No warning as it should be suppressed by the allow attribute.
Version
rustc 1.89.0 (29483883e 2025-08-04)
binary: rustc
commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2
commit-date: 2025-08-04
host: aarch64-apple-darwin
release: 1.89.0
LLVM version: 20.1.7
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing