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
2 changed files with 14 additions and 2 deletions
+1 -1
View File
@@ -74,7 +74,7 @@
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(
+13 -1
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();