Skip to content

Commit 430c02c

Browse files
committed
large_enum_variant: Delay macro check
1 parent 3092c8a commit 430c02c

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

clippy_lints/src/large_enum_variant.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,12 @@ impl_lint_pass!(LargeEnumVariant => [LARGE_ENUM_VARIANT]);
7777

7878
impl<'tcx> LateLintPass<'tcx> for LargeEnumVariant {
7979
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &Item<'tcx>) {
80-
if in_external_macro(cx.tcx.sess, item.span) {
81-
return;
82-
}
83-
if let ItemKind::Enum(ref def, _) = item.kind {
84-
let ty = cx.tcx.type_of(item.owner_id).instantiate_identity();
85-
let ty::Adt(adt, subst) = ty.kind() else {
86-
panic!("already checked whether this is an enum")
87-
};
88-
if adt.variants().len() <= 1 {
89-
return;
90-
}
80+
if let ItemKind::Enum(ref def, _) = item.kind
81+
&& let ty = cx.tcx.type_of(item.owner_id).instantiate_identity()
82+
&& let ty::Adt(adt, subst) = ty.kind()
83+
&& adt.variants().len() > 1
84+
&& !in_external_macro(cx.tcx.sess, item.span)
85+
{
9186
let variants_size = AdtVariantInfo::new(cx, *adt, subst);
9287

9388
let mut difference = variants_size[0].size - variants_size[1].size;

0 commit comments

Comments
 (0)