Skip to content

Commit

Permalink
inline non_exhaustive def/variant check
Browse files Browse the repository at this point in the history
  • Loading branch information
rmehri01 committed Oct 17, 2023
1 parent 7684b8b commit 45dd973
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 45dd973

Please sign in to comment.