diff options
| author | Nadrieril <nadrieril+git@gmail.com> | 2024-08-10 19:06:26 +0200 |
|---|---|---|
| committer | Nadrieril <nadrieril+git@gmail.com> | 2024-09-02 21:16:37 +0200 |
| commit | 6f6a6bc710e538741aa06d40df6492471e4be8af (patch) | |
| tree | 61e1807182b71b1cf086f8b63077391c7d8a3607 /compiler/rustc_pattern_analysis/src/rustc.rs | |
| parent | bd53aa3bf7a24a70d763182303bd75e5fc51a9af (diff) | |
| download | rust-6f6a6bc710e538741aa06d40df6492471e4be8af.tar.gz rust-6f6a6bc710e538741aa06d40df6492471e4be8af.zip | |
Non-exhaustive structs may be empty
Diffstat (limited to 'compiler/rustc_pattern_analysis/src/rustc.rs')
| -rw-r--r-- | compiler/rustc_pattern_analysis/src/rustc.rs | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/compiler/rustc_pattern_analysis/src/rustc.rs b/compiler/rustc_pattern_analysis/src/rustc.rs index d7885e05a2f..6c09f97bfe7 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -229,17 +229,11 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { } else { let variant = &adt.variant(RustcPatCtxt::variant_index_for_adt(&ctor, *adt)); - - // In the cases of either a `#[non_exhaustive]` field list or a non-public - // field, we skip uninhabited fields in order not to reveal the - // uninhabitedness of the whole variant. - let is_non_exhaustive = - variant.is_field_list_non_exhaustive() && !adt.did().is_local(); let tys = cx.variant_sub_tys(ty, variant).map(|(field, ty)| { let is_visible = adt.is_enum() || field.vis.is_accessible_from(cx.module, cx.tcx); let is_uninhabited = cx.is_uninhabited(*ty); - let skip = is_uninhabited && (!is_visible || is_non_exhaustive); + let skip = is_uninhabited && !is_visible; (ty, PrivateUninhabitedField(skip)) }); cx.dropless_arena.alloc_from_iter(tys) |
