Skip to content

Commit

Permalink
We don't need to check for non-exhaustive fields
Browse files Browse the repository at this point in the history
Fields are disallowed so checking the top attribute is enough.
  • Loading branch information
MasterAwesome committed Apr 24, 2024
1 parent fc37633 commit b3e6d52
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions compiler/rustc_lint/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,8 +1114,7 @@ fn is_niche_optimization_candidate<'tcx>(

match ty.kind() {
ty::Adt(ty_def, _) => {
let non_exhaustive = ty_def.is_variant_list_non_exhaustive()
|| ty_def.variants().iter().any(|variant| variant.is_field_list_non_exhaustive());
let non_exhaustive = ty_def.is_variant_list_non_exhaustive();
let contains_no_fields = ty_def.all_fields().next().is_none();

!non_exhaustive && contains_no_fields
Expand Down

0 comments on commit b3e6d52

Please sign in to comment.