From 45dd97359996aa2279f08c22427b079dd6514e1d Mon Sep 17 00:00:00 2001 From: Ryan Mehri Date: Tue, 17 Oct 2023 08:29:17 -0700 Subject: [PATCH] inline non_exhaustive def/variant check --- compiler/rustc_lint/src/builtin.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index ba764443f8c03..12e818b81cb39 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -677,7 +677,9 @@ impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations { if type_implements_negative_copy_modulo_regions(cx.tcx, ty, param_env) { return; } - if def_or_variant_marked_non_exhaustive(def) { + if def.is_variant_list_non_exhaustive() + || def.variants().iter().any(|variant| variant.is_field_list_non_exhaustive()) + { return; } @@ -733,11 +735,6 @@ fn type_implements_negative_copy_modulo_regions<'tcx>( tcx.infer_ctxt().build().predicate_must_hold_modulo_regions(&obligation) } -fn def_or_variant_marked_non_exhaustive<'tcx>(def: ty::AdtDef<'tcx>) -> bool { - def.is_variant_list_non_exhaustive() - || def.variants().iter().any(|variant| variant.is_field_list_non_exhaustive()) -} - declare_lint! { /// The `missing_debug_implementations` lint detects missing /// implementations of [`fmt::Debug`] for public types.