diff options
| author | bors <bors@rust-lang.org> | 2023-09-02 10:14:33 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-09-02 10:14:33 +0000 |
| commit | 7cf96dabb7700160823a90ee1a0302069948ebad (patch) | |
| tree | 850b899186c1bba5c5e83b2ad2d77ce9148a7848 | |
| parent | a45feda736148476f58ea593daabc61c0f485fed (diff) | |
| parent | 79e31cb80ea78dbfe67597fcff2f2a5d4d172f8d (diff) | |
Auto merge of #11448 - RalfJung:DefaultUnionRepresentation, r=blyxyas
DefaultUnionRepresentation: explain why we only warn about unions with at least 2 non-ZST fields changelog: none
| -rw-r--r-- | clippy_lints/src/default_union_representation.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clippy_lints/src/default_union_representation.rs b/clippy_lints/src/default_union_representation.rs index 03b5a2d6d08..bbce6e1dd8f 100644 --- a/clippy_lints/src/default_union_representation.rs +++ b/clippy_lints/src/default_union_representation.rs @@ -69,6 +69,9 @@ impl<'tcx> LateLintPass<'tcx> for DefaultUnionRepresentation { } /// Returns true if the given item is a union with at least two non-ZST fields. +/// (ZST fields having an arbitrary offset is completely inconsequential, and +/// if there is only one field left after ignoring ZST fields then the offset +/// of that field does not matter either.) fn is_union_with_two_non_zst_fields(cx: &LateContext<'_>, item: &Item<'_>) -> bool { if let ItemKind::Union(data, _) = &item.kind { data.fields().iter().filter(|f| !is_zst(cx, f.ty)).count() >= 2 |
