mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-19 19:23:10 +00:00
Fix false-positive debug_assert
in panic
This commit is contained in:
parent
fd5cf4e82d
commit
cb14e7ebf4
@ -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(
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user