-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Closed
Copy link
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
expect(clippy::collapsible_else_if) falsely reports "this lint expectation is unfulfilled" when used inside the else block:
Lint Name
clippy::collapsible_else_if
Reproducer
fn main() {
// Correctly detected as collapsible:
if true {
} else {
if false {}
}
// Allowing the lint silences it both inside the `else` block:
if true {
} else {
#[allow(clippy::collapsible_else_if)]
if false {}
}
// ... and before the entire `if`:
#[allow(clippy::collapsible_else_if)]
if true {
} else {
if false {}
}
// Using `expect` inside the `else` block says "this lint expectation is unfulfilled":
if true {
} else {
#[expect(clippy::collapsible_else_if)]
if false {}
}
// This works correctly, however:
#[expect(clippy::collapsible_else_if)]
if true {
} else {
if false {}
}
}Version
rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.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 thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have