Do not trigger trailing_empty_array in tests
This commit is contained in:
parent
c2d23ad0df
commit
a5d5edc581
2 changed files with 19 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_help;
|
||||
use clippy_utils::has_repr_attr;
|
||||
use clippy_utils::{has_repr_attr, is_in_test};
|
||||
use rustc_hir::{Item, ItemKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty;
|
||||
|
|
@ -37,7 +37,10 @@ declare_lint_pass!(TrailingEmptyArray => [TRAILING_EMPTY_ARRAY]);
|
|||
|
||||
impl<'tcx> LateLintPass<'tcx> for TrailingEmptyArray {
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
|
||||
if is_struct_with_trailing_zero_sized_array(cx, item) && !has_repr_attr(cx, item.hir_id()) {
|
||||
if is_struct_with_trailing_zero_sized_array(cx, item)
|
||||
&& !has_repr_attr(cx, item.hir_id())
|
||||
&& !is_in_test(cx.tcx, item.hir_id())
|
||||
{
|
||||
span_lint_and_help(
|
||||
cx,
|
||||
TRAILING_EMPTY_ARRAY,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue