ignore assertions-on-constants in const contexts
This commit is contained in:
parent
e18b27aa2a
commit
ac600282a0
3 changed files with 6 additions and 26 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use clippy_utils::consts::{constant_with_source, Constant, ConstantSource};
|
||||
use clippy_utils::diagnostics::span_lint_and_help;
|
||||
use clippy_utils::is_inside_always_const_context;
|
||||
use clippy_utils::macros::{find_assert_args, root_macro_call_first_node, PanicExpn};
|
||||
use rustc_hir::{Expr, Item, ItemKind, Node};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
|
|
@ -31,6 +32,10 @@ declare_lint_pass!(AssertionsOnConstants => [ASSERTIONS_ON_CONSTANTS]);
|
|||
|
||||
impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants {
|
||||
fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
|
||||
if is_inside_always_const_context(cx.tcx, e.hir_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
let Some(macro_call) = root_macro_call_first_node(cx, e) else {
|
||||
return;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue