use rustc_errors::Applicability;
use rustc_hir::{Item, ItemKind, VariantData};
use rustc_lint::{LateContext, LateLintPass};
+use rustc_middle::lint::in_external_macro;
use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_target::abi::LayoutOf;
impl<'tcx> LateLintPass<'tcx> for LargeEnumVariant {
fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
- let did = cx.tcx.hir().local_def_id(item.hir_id);
+ if in_external_macro(cx.tcx.sess, item.span) {
+ return;
+ }
if let ItemKind::Enum(ref def, _) = item.kind {
- let ty = cx.tcx.type_of(did);
+ let ty = cx.tcx.type_of(item.def_id);
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");
let mut largest_variant: Option<(_, _)> = None;