-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
Description
Summary
diverging_sub_expression
triggers on … || diverge()
but not … || { diverge(); }
. It should trigger equivalently on both.
This came up due to rust-lang/rust#104134 breaking this test in clippy:
rust-clippy/tests/ui/diverging_sub_expression.stderr
Lines 33 to 37 in a167973
error: sub-expression diverges | |
--> $DIR/diverging_sub_expression.rs:36:30 | |
| | |
LL | _ => true || panic!("boo"), | |
| ^^^^^^^^^^^^^ |
due to the panic!
expansion changing from core::panicking::panic_fmt(…)
to { core::panicking::panic_fmt(…); }
.
Lint Name
diverging_sub_expression
Reproducer
True positive:
fn main() {
let lhs = false;
let _ = lhs || return;
}
$ cargo clippy
warning: sub-expression diverges
--> src/main.rs:3:20
|
3 | let _ = lhs || return;
| ^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#diverging_sub_expression
= note: `#[warn(clippy::diverging_sub_expression)]` on by default
False negative:
fn main() {
let lhs = false;
let _ = lhs || { return; };
}
$ cargo clippy
... nothing
Version
rustc 1.71.0-nightly (2c41369ac 2023-05-13)
binary: rustc
commit-hash: 2c41369acc445d04129db40ba998dd7a89fb0d2e
commit-date: 2023-05-13
host: aarch64-apple-darwin
release: 1.71.0-nightly
LLVM version: 16.0.2
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't