DefaultUnionRepresentation: explain why we only warn about unions with at least 2 non-ZST fields
This commit is contained in:
parent
a8b5245ea3
commit
79e31cb80e
@ -69,6 +69,9 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
|
||||
}
|
||||
|
||||
/// 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
|
||||
|
Loading…
Reference in New Issue
Block a user