-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-needs-testCall for participation: writing testsCall for participation: writing testsgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
The following code:
if let Some(data_sub) = &data.get(range) {
*data_sub
} else {
debug_assert!(false, "Out-of-bounds read. ");
}
Triggers assertion_on_constants
for me. https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants explains that this assertion would be optimized out by the compiler. That shouldn't be so. A statically false assertion should become a panic, not be optimized away. Since this assertion is only triggered in debug builds, using a plain unreachable!
or panic!
isn't an equivalent alternative. So as long as debug_unreachable!
isn't part of the standard library, this lint should not fire in cases like the above. Furthermore, the lint explanation should be corrected to say that (only) statically true assertions may be optimized out.
clippy 0.0.212 (6ce78d12 2019-01-29)
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-needs-testCall for participation: writing testsCall for participation: writing testsgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy