mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
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
1 changed files with 3 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue