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
This commit is contained in:
commit
7cf96dabb7
@ -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.
|
/// 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 {
|
fn is_union_with_two_non_zst_fields(cx: &LateContext<'_>, item: &Item<'_>) -> bool {
|
||||||
if let ItemKind::Union(data, _) = &item.kind {
|
if let ItemKind::Union(data, _) = &item.kind {
|
||||||
data.fields().iter().filter(|f| !is_zst(cx, f.ty)).count() >= 2
|
data.fields().iter().filter(|f| !is_zst(cx, f.ty)).count() >= 2
|
||||||
|
Loading…
Reference in New Issue
Block a user