rust/compiler
Matthias Krüger 91f70a8fdf
Rollup merge of #94031 - danielhenrymantilla:diagnostics/union-drop-suggest-copy-bound-alternative, r=davidtwco
[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
2022-02-17 06:30:03 +01:00
..
2022-02-15 16:19:59 +11:00
2022-02-15 16:19:59 +11:00
2022-02-15 16:19:59 +11:00
2022-02-13 11:49:52 +01:00
2022-02-13 11:49:52 +01:00
2022-02-15 16:19:59 +11:00
2022-02-15 16:19:59 +11:00
2022-02-15 16:03:24 +11:00
2022-02-15 16:19:59 +11:00
2022-02-12 11:23:53 +00:00
2022-02-15 16:19:59 +11:00
2022-02-15 16:19:59 +11:00
2022-02-15 16:19:59 +11:00
2022-02-15 19:08:12 +01:00
2022-02-15 16:19:59 +11:00