]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #94031 - danielhenrymantilla:diagnostics/union-drop-suggest-copy...
authorMatthias Krüger <matthias.krueger@famsik.de>
Thu, 17 Feb 2022 05:30:03 +0000 (06:30 +0100)
committerGitHub <noreply@github.com>
Thu, 17 Feb 2022 05:30:03 +0000 (06:30 +0100)
[diagnostics] Add mentions to `Copy` types being valid for `union` fields

This came up from some user on Discord which was using a `T : PrimitiveInt` generic type, and they wanted to use in a `union`. Rather than adding a `Copy` bound, they started pondering about the `ManuallyDrop<T>` road, and how to correctly use `unsafe` to perform the drops.

<img width="648" alt="Screen Shot 2022-02-15 at 22 28 34" src="https://user-images.githubusercontent.com/9920355/154152496-8f9be74b-ad59-4724-8f9e-48b446774e06.png">

  - [Discord link](https://discord.com/channels/442252698964721669/443150878111694848/943092778534072320)

So, it seemed like the error message for types with potential drop glue on `union` fields could be improved to also mention the `Copy` alternative, since in many cases where `union`s are concerned, people are dealing with PODs / `Copy` types anyways 🙂

___

``@rustbot`` modify labels: +A-diagnostics +D-terse


No differences found