Document how removing a type's field can be bad and what to do instead

Related to #119645
This commit is contained in:
Jake Goulding 2024-03-02 09:55:06 -05:00
parent 3314d5ce4c
commit 71080dd1d4

View File

@ -702,6 +702,20 @@ declare_lint! {
/// `PhantomData`.
///
/// Otherwise consider removing the unused code.
///
/// ### Limitations
///
/// Removing fields that are only used for side-effects and never
/// read will result in behavioral changes. Examples of this
/// include:
///
/// - If a field's value performs an action when it is dropped.
/// - If a field's type does not implement an auto trait
/// (e.g. `Send`, `Sync`, `Unpin`).
///
/// For side-effects from dropping field values, this lint should
/// be allowed on those fields. For side-effects from containing
/// field types, `PhantomData` should be used.
pub DEAD_CODE,
Warn,
"detect unused, unexported items"