Fix false-positive debug_assert in panic

This commit is contained in:
daxpedda 2021-04-10 23:37:18 +02:00
parent fd5cf4e82d
commit cb14e7ebf4
No known key found for this signature in database
GPG Key ID: 43D62A3EA388E46F
2 changed files with 14 additions and 2 deletions

View File

@ -74,7 +74,7 @@ declare_lint_pass!(PanicUnimplemented => [UNIMPLEMENTED, UNREACHABLE, TODO, PANI
impl<'tcx> LateLintPass<'tcx> for PanicUnimplemented {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
if match_panic_call(cx, expr).is_some() {
if match_panic_call(cx, expr).is_some() && is_expn_of(expr.span, "debug_assert").is_none() {
let span = get_outer_span(expr);
if is_expn_of(expr.span, "unimplemented").is_some() {
span_lint(

View File

@ -1,5 +1,5 @@
#![warn(clippy::unimplemented, clippy::unreachable, clippy::todo, clippy::panic)]
#![allow(clippy::assertions_on_constants)]
#![allow(clippy::assertions_on_constants, clippy::eq_op)]
extern crate core;
@ -43,6 +43,18 @@ fn core_versions() {
unreachable!();
}
fn debug_assert() {
debug_assert!(true);
debug_assert_eq!(true, true);
debug_assert_ne!(true, false);
}
fn debug_assert_msg() {
debug_assert!(true, "test");
debug_assert_eq!(true, true, "test");
debug_assert_ne!(true, false, "test");
}
fn main() {
panic();
todo();